• 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: Referencing an object after sending a release message to it
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Referencing an object after sending a release message to it


  • Subject: Re: Referencing an object after sending a release message to it
  • From: Scott Ribe <email@hidden>
  • Date: Sat, 06 Aug 2011 15:36:47 -0600

On Aug 6, 2011, at 3:06 PM, Jon Boone wrote:

> Is it dangerous to send the release message to p right after adding it to the array?  Should I put the release at the end of the method?

You should release it when you're done with it. Granted, you can probably get away with it here, under a reasonable set of assumptions: employeeController actually retains it, rather than copying it, or just using it in the addObject method and not keeping a reference to it, and rearrangedObjects doesn't cause it to be released, and there's not some background thread that will modify employeeController and release it asynchronously.

But it would be a terrible habit to get in to. (Note how many assumptions it relies on...)

--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice




_______________________________________________

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: Referencing an object after sending a release message to it
      • From: Thomas Wetmore <email@hidden>
References: 
 >Referencing an object after sending a release message to it (From: Jon Boone <email@hidden>)

  • Prev by Date: NSPersistentDocument: SQLite error 21 on save
  • Next by Date: Re: Referencing an object after sending a release message to it
  • Previous by thread: Referencing an object after sending a release message to it
  • Next by thread: Re: Referencing an object after sending a release message to it
  • Index(es):
    • Date
    • Thread