• 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
Re: How to clone a mutable dictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >How to clone a mutable dictionary (From: Steve Cronin <email@hidden>)

  • Prev by Date: Re: Best technology to use for overlays?
  • Next by Date: Re: Best technology to use for overlays?
  • Previous by thread: Re: How to clone a mutable dictionary
  • Next by thread: RE: How to clone a mutable dictionary
  • Index(es):
    • Date
    • Thread