Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionary and retaining values




On Apr 18, 2008, at 10:58 AM, Optical Ali wrote:

Does NSDictionary retain the objects (values) that are added?
Shouldn't "n" be 2 below?


You're making an assumption about the implementation of NSDictionary. You're also either trying to learn about reference counting in general, or trying to troubleshoot a memory management problem, by looking at reference count at runtime. None of the above seems like a good idea.

The important thing to keep in mind and focus on is the contract: You need to balance your "reference count increasing" calls with your "reference count decreasing" calls. That is your part of the contract.
Trust that the libraries and frameworks that you use does the right thing, they typically have few memory management bugs as they get a LOT of testing by virtue of being shared with so many developers and end users.


If you're trying to find a memory leak, there are memory management troubleshooting tools better suited for that purpose. A very good place to start is using the "Leaks" template of Instruments.

j o a r


_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/objc-language/email@hidden

This email sent to email@hidden
References: 
 >NSDictionary and retaining values (From: "Optical Ali" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.