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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to