• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Making an object release itself?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Making an object release itself?
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: Visualization strategy/choosing a framework
  • Next by Date: Re: Which language to get started with cocoa development?
  • Previous by thread: Scripting Bridge: Targeting Another Mac on the LAN
  • Next by thread: Re: Making an object release itself?
  • Index(es):
    • Date
    • Thread