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!
精彩评论