• 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
immutable copy of NSMutableDictionary but not a deep copy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

immutable copy of NSMutableDictionary but not a deep copy


  • Subject: immutable copy of NSMutableDictionary but not a deep copy
  • From: Ben Dougall <email@hidden>
  • Date: Wed, 1 Mar 2006 16:29:53 +0000

what's the best way of getting an immutable copy of an instance of NSMutableDictionary without duplicating the objects in the NSMutableDictionary instance? the NSMutableDictionary instance contains, other than the NSString keys, objects of my own class that are subclasses of NSObject.

NSMutableDictionary *md = something that provides a mutable dictionary
NSDictionary *d = [md copy];

gives an error ([MyObject copyWithZone:]: selector not recognized) because my objects in md don't conform to the NSCopying protocol. but, i don't want to duplicate the instances of my objects (nor the strings that are keys) -- i want to use the same objects, so the same pointers, which are in the NSMutableDictionary instance.

should i make my objects conform to the NSCopying protocol and implement the copyWithZone method and in that just have return self; in it? or use NSDictionary's initWithDictionary: method? or something else?

thanks, ben.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: immutable copy of NSMutableDictionary but not a deep copy
      • From: Ben Dougall <email@hidden>
  • Prev by Date: Re: Need Help Please....Truncation Mode for Window Title
  • Next by Date: Re: Core Data threading again
  • Previous by thread: Re: NSDocument saveDocumentAs with suggested name
  • Next by thread: Re: immutable copy of NSMutableDictionary but not a deep copy
  • Index(es):
    • Date
    • Thread