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

Re: immutable copy of NSMutableDictionary but not a deep copy


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

oops sorry, forget this. i was actually getting the copyWithZone error from a different line ([md setObject:obj forKey:name];), not the [md copy] line which i thought it was.

On Wednesday, March 1, 2006, at 04:29  pm, Ben Dougall wrote:

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
References: 
 >immutable copy of NSMutableDictionary but not a deep copy (From: Ben Dougall <email@hidden>)

  • Prev by Date: Re: Core Data threading again
  • Next by Date: Re: Programmatically setting the value of a bound TextField
  • Previous by thread: immutable copy of NSMutableDictionary but not a deep copy
  • Next by thread: [Newbie] Creating a timeline view
  • Index(es):
    • Date
    • Thread