Re: Memory Management and objects creation via static methods...
Re: Memory Management and objects creation via static methods...
- Subject: Re: Memory Management and objects creation via static methods...
- From: Jens Alfke <email@hidden>
- Date: Mon, 24 Mar 2008 21:54:16 -0700
On 24 Mar '08, at 9:19 PM, Samvel wrote:
Should I retain string in init?
Yes. When you store an object pointer in an instance variable you
almost always want to retain it, so the object pointed to won't get
deleted. If the pointer came from an "init" method, that object is
already retained and you can just assign it to the instance variable.
But if you got it through any other source, including a class factory
method like +[NSString stringWith....], then the object has _not_ been
retained for you, and if you want to keep a reference you'll need to
call -retain yourself.
…Or you could just enable garbage collection and not have to deal with
all this crap. It just means your app will require 10.5 or later.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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