Re: How to clone a mutable dictionary
Re: How to clone a mutable dictionary
- Subject: Re: How to clone a mutable dictionary
- From: Andy Lee <email@hidden>
- Date: Fri, 24 Apr 2009 07:45:29 -0400
On Apr 24, 2009, at 4:35 AM, Steve Cronin wrote:
Everything I do causes any change I make in newThing2 to also be
made in newThing.
newThing2 = [NSMutableDictionary dictionaryWithCapacity:20];
[newThing2 setDictionary:newThing];
[newThing2 setObject:foo forKey:bar]; // at this method line
[newThing objectForKey:bar] is now foo
This should work. Are you sure you don't have a typo somewhere?
The symptoms you describe suggest that newThing == newThing2. What if
you NSLog(@"%d", newThing == newThing2)? Maybe you're overreleasing
newThing and newThing2 is using newThing's dealloc'ed memory?
Are you setting up bindings somewhere that might be replicating
changes in newThing to newThing2?
--Andy
_______________________________________________
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