• 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
Confused about Memory Management with Collections
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Confused about Memory Management with Collections


  • Subject: Confused about Memory Management with Collections
  • From: "Mazen M. Abdel-Rahman" <email@hidden>
  • Date: Sat, 28 Nov 2009 14:19:46 -0700

Hi All,

I am trying to find out how memory is retained/released when using different Cocoa collection classes.  Is there a good resource on this anyone can connect me to?

Here is some detailed questions about what I am trying to find out:

If I create a dictionary in the following manner (where myArray is an NSArray* and authorName is an NSString*)

NSDictionary * myDict = [NSDictionary dictionaryWithObjectsAndKeys:myArray, @"Titles", authorName, @"Name",nil];

Does this call automatically increase the retain count of myArray and authorName?  So that I should call release on them if I don't need to have them anywhere else outside the dictionary?  Or will calling release on them mess up the dictionary?

Also - once I am done with this dictionary -  since I created it using a class method (and not alloc) - am I right in assuming that I should not call release on it?  And if that is the case when does it get released?

Thanks for your help!
Mazen Abdel-Rahman
_______________________________________________

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: Confused about Memory Management with Collections
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: Apache Module
  • Next by Date: Re: Confused about Memory Management with Collections
  • Previous by thread: Re: Cast NSNumber to int
  • Next by thread: Re: Confused about Memory Management with Collections
  • Index(es):
    • Date
    • Thread