Question

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

attString = [[NSMutableAttributedString alloc] init];

On a loop, I want to clear the contents of attString and re-use it. How do I do this?

Thanks!

Was it helpful?

Solution

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

OTHER TIPS

[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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top