• 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
Question about scope of "convenience objects"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Question about scope of "convenience objects"
      • From: "I. Savant" <email@hidden>
    • Re: Question about scope of "convenience objects"
      • From: Charles Steinman <email@hidden>
    • Re: Question about scope of "convenience objects"
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: Need help with -mutableSetValueForKey:
  • Next by Date: Re: Question about scope of "convenience objects"
  • Previous by thread: Re: Need help with -mutableSetValueForKey:
  • Next by thread: Re: Question about scope of "convenience objects"
  • Index(es):
    • Date
    • Thread