Re: NSMutableArray, NSMutableDictionary memory managment
Re: NSMutableArray, NSMutableDictionary memory managment
- Subject: Re: NSMutableArray, NSMutableDictionary memory managment
- From: Jamie Hardt <email@hidden>
- Date: Thu, 11 Sep 2008 10:44:16 -0700
I'd also hasten to remind that collections retain their objects, but
if those objects are mutable, like NSMutableString, than anybody that
holds a ref to them can change them at any time, so in some cases you
do want to make deep or immutable copies of these objects, depending
on context. I've been bitten by this before.
On Sep 11, 2008, at 10:32 AM, infinite labs wrote:
On Thu, Sep 11, 2008 at 7:18 PM, Jamie Hardt <email@hidden>
wrote:
"Arrays maintain strong references to their contents—in a managed
memory
environment, each object receives a retain message before its id is
added to
the array and a release message when it is removed from the array
or when
the array is deallocated. If you want a collection with different
object
ownership semantics, consider using CFArray Reference,
NSPointerArray, or
NSHashTable instead."
Word of warning: NSPointerArray and NSHashTable (the 10.5 class)
aren't available on the iPhone, but CFDictionary with proper callbacks
set can replace them.
- ∞
Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/
_______________________________________________
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