Question about scope of "convenience objects"
Question about scope of "convenience objects"
- Subject: Question about scope of "convenience objects"
- From: Paul Bruneau <email@hidden>
- Date: Fri, 21 Sep 2007 11:10:06 -0400
I am wanting to use an NSDictionary object to return multiple values
from one of my methods. As soon as the dictionary object is returned,
I pull the contents out of it.
My first thinking was to create it with dictionaryWithObjectsAndKeys:
then return it.
But then I got nervous that it would release and dealloc at the end
of the method, leaving me with an invalid pointer getting returned.
But upon reading the simple rules at
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
Tasks/MemoryManagementRules.html
they say "A received object is normally guaranteed to remain valid
within the method it was received in...That method may also safely
return the object to its invoker."
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?
Thank you
_______________________________________________
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