Re: immutable copy of NSMutableDictionary but not a deep copy
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