开发者

How can I clear the contents of an NSMutableAttributedString?

I have an ivar which is alloc-inited in the init of an object:

attString = [[NSMutableAttributedString alloc] init];

On a loo开发者_Python百科p, I want to clear the contents of attString and re-use it. How do I do this?

Thanks!


[[attString mutableString] setString:@""];


[attString release];
attString = [[NSMutableAttributedString alloc] init];

Kenny's method probably quicker.


I didn't find out the methods that @kennytm mentioned above, but I did it with this:

[attriString setAttributedString:[NSAttributedString new]];

Available from mac10.0 and ios3.2 or later. Good luck for new searchers!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜