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

How to clone a mutable dictionary


  • Subject: How to clone a mutable dictionary
  • From: Steve Cronin <email@hidden>
  • Date: Fri, 24 Apr 2009 03:35:19 -0500

Folks;

Its been a long day and maybe I'm just in need of sleep but I'm bamboozeled...

I have an NSMutableDictionary (newThing) that is set up based on some user defaults and current contextual data.
newThing is fine.


What I want to do is clone newThing (newThing2) and leave the values in newThing alone.
(I'll want to come and get newThing3 sooner or later)


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


I've tried [newThing copy) and enumerating over [newThing allKeys] doing a [newThing2 setObject:forKey]...
All with the same result....


How do I make an independent clone of newThing1?   (XC3  / 10.5.6)

I'm sorry if this is something silly!
Steve
_______________________________________________

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: How to clone a mutable dictionary
      • From: Andy Lee <email@hidden>
    • Re: How to clone a mutable dictionary
      • From: Jean-Daniel Dupas <email@hidden>
    • Re: How to clone a mutable dictionary
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Problem implementing keyPathsForvaluesAffecting<Key>
  • Next by Date: Re: How to clone a mutable dictionary
  • Previous by thread: Snow Leopard DevForums Now Available
  • Next by thread: Re: How to clone a mutable dictionary
  • Index(es):
    • Date
    • Thread