Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
- Subject: Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
- From: Nicko van Someren <email@hidden>
- Date: Mon, 7 Jun 2004 17:40:50 +0100
On 7 Jun 2004, at 17:11, Marcel Weiher wrote:
Nicko: one of the reasons that the current implementation is broken
is that it *cannot* be fixed easily by subclassing!
That depends on what you call easy. It's trivial to do if you use a
wrapper class like this (typed in Mail.app):
@interface RefWrapper : NSObject <NSCopying> {
id theRef;
}
- (id) initWithRef: (id) ref;
- (id) copyWithZone;
- (id) getRef;
@end
@implementation RefWrapper {
- (id) initWithRef: (id) ref { theRef = ref; return self; }
- (id) copyWithZone { return [[RefWrapper alloc] initWithRef: theRef]; }
- (id) getRef { return theRef; }
- (unsigned) hash { return [theRef hash]; }
- (BOOL) isEqual: (id) X { if [X isKindOfClass: [self class]] return
[theRef isEqual: [X getRef]]; return NO; }
@end
Whereas the copying behavior *can* be added to a non-copying
implementation via subclassing.
It seems to me, looking at the documentation, that there are only two
extra messages that would have to be overridden to make the non-copying
version from what we have using the above wrapper class (objectForKey:
and keyEnumerator).
That was one of the original points I made.
It would really help if people would (a) read and (b) understand what
was written before responding.
I did read and understand your previous postings, I just happen to
disagree with them.
Nicko
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.