Re: Retaining a NSURL and retaining its -path
Re: Retaining a NSURL and retaining its -path
- Subject: Re: Retaining a NSURL and retaining its -path
- From: Greg Guerin <email@hidden>
- Date: Sat, 12 Sep 2009 10:21:58 -0700
John Love wrote:
My first attempt was to pass that NSURL in the same manner and then
place the extracted [myURL path] into an instance variable of the
2nd controller. Okay so far .. and then I assumed that if myURL was
retained in the 1st controller, then "naturally" its NSString -path
was also retained ..
If that was your "natural" assumption, then you haven't memorized the
memory management rules. Reread them and see where -path's return
value fits in the scheme. The rules are simple enough to remember,
and you will use them every day, so there is value in memorization.
but it crashed with "release message sent to a already released
object" (or something like that). Only when I extracted the -path
*and* retained it before I stored it as an instance variable of the
2nd controller did it work.
Why wouldn't you retain -path anyway? It's being used by another
controller object. What would you hope to gain by not retaining it?
Extra speed? Sounds like premature optimization.
Basic question: if a parent object is retained, why isn't each
sibling component object of that parent retained??
How do you know it's not? Is your code implementing the parent
object (NSURL in this case)? If not, then under what memory
management rule can you assume ownership of the component objects?
-- GG
_______________________________________________
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