Re: Question about scope of "convenience objects"
Re: Question about scope of "convenience objects"
- Subject: Re: Question about scope of "convenience objects"
- From: "I. Savant" <email@hidden>
- Date: Fri, 21 Sep 2007 11:30:03 -0400
> So it looks like I am ok after all to use my NSDictionaryObject in
> the method that called the method in which the object was created. Is
> this correct?
How do you think dictionaries and arrays of things are handed back
to you from other Cocoa methods? A hint: the same way. :-) If you
weren't able to rely on the object being returned sticking around long
enough for you to at least retain it, nothing would work right.
I see some prefer the style (on a "getter" accessor method) of:
return [[object retain] autorelease];
But the memory management guide says simply returning the object is
sufficient: "... no need for retain or release:". Given that, I don't
think that really buys you anything in the general case.
FWIW, I use the "hand back a dictionary to return multiple values"
approach frequently. It's (IMHO) a natural use of such a "throw-away"
container.
--
I.S.
_______________________________________________
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