Re: Making an object release itself?
Re: Making an object release itself?
- Subject: Re: Making an object release itself?
- From: Jim Correia <email@hidden>
- Date: Thu, 1 Jan 2009 14:00:04 -0500
On Dec 30, 2008, at 10:28 PM, Jacob Rhoden wrote:
Im still learning cocoa, so I have a question about if this is a
good idea or a crazy noob mistake. Given the following code can I
alter it so that postreader auto releases itself?
[...]
I'm thinking PostReader class could have a static function that
initialises a new PostReader object, tells it to start the work, and
then do a [self release] after it has called the callback function
'postsRead';
In a retain/release world, having the helper object own itself, and
remove that reference when its async work is complete (and it has
posted the results somewhere) is generally OK.
If you intend this code to work in a GC environment though, you must
make sure your helper object is rooted, or some other object keeps a
strong reference to it, until the async work is complete, otherwise it
will be collected.
Jim
_______________________________________________
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