Re: Subclassing NS(Mutable)Dictionary
Re: Subclassing NS(Mutable)Dictionary
- Subject: Re: Subclassing NS(Mutable)Dictionary
- From: email@hidden
- Date: Tue, 23 Jul 2002 19:17:18 -0400
This is what I was looking for. Thank you.
On Tuesday, July 23, 2002, at 06:51 PM, Ondra Cada wrote:
In short, by not subclassing, but embedding (as the Class Cluster
document says, or at least, had said when I've learnt it brand new in
OpenStep ages ago).
Make a new class with API you like, and make it contain the appropriate
objects -- something like
@interface OrderedDict {
NSMutableArray *array;
NSMutableDictionary *dictionary;
}
...
-(void)setObject:o forKey:k;
...
@end
@implementation OrderedDict
...
-(void)setObject:o forKey:k {
[dictionary setObject:o forKey:k];
[array addObject:k];
[array sortUsingSelector:@selector(caseInsensitiveCompare:)];
}
...
@end
_______________________________________________
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.