Re: NSMutableString question
Re: NSMutableString question
- Subject: Re: NSMutableString question
- From: Dave DeLong <email@hidden>
- Date: Tue, 16 Sep 2008 18:59:48 -0600
The general rule with convenience class methods like that is that they
return an autoreleased object. What that means is that unless you
retain it, it will disappear at some time in the future (whenever the
current AutoreleasePool gets drained).
So if you want to "reclaim" the space, you don't have to do anything.
If you want to reclaim it immediately, I think you ought to be able to
do:
NSString * str = [NSMutableString string];
//do stuff with str
[[str retain] release];
HOWEVER, that might cause funky things to happen with the autorelease
pool. So the best idea is to do nothing and let the autorelease pool
take care of it.
HTH,
Dave
On 16 Sep, 2008, at 6:56 PM, John Zorko wrote:
Hello, all ...
I've another simple ObjC question that I hope someone can answer --
this has to do with memory management and NSMutableString. If I do
this:
NSString *str = [NSMutableString string];
... what is the best way to reclaim that space? Do I do [str
release] (no alloc was called by me, so I think not, but i'm not
sure), or str = nil, or something else?
Regards,
John
Falling You - exploring the beauty of voice and sound
http://www.fallingyou.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden