Re: Referencing an object after sending a release message to it
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