RE: Subclassing dictionaries?
RE: Subclassing dictionaries?
- Subject: RE: Subclassing dictionaries?
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Thu, 4 Sep 2003 11:34:43 -0400
>
What I'd like to do is subclass a dictionary, so that it has a
>
method where
>
it can receive a sort key - you could set that based on NSArray's
>
- (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject
>
>
If I implement a comparison method based on the sort key in my subclass, I
>
can then call
>
- (NSArray *)sortedArrayUsingSelector:(SEL)comparator
>
To do the sorting.
Use a category. It's much easier than subclassing clusters.
Generally speaking, if all you want to do is add a method to an object, and
you don't need to add instance variables, categories are easier and more
straightforward than subclassing.
BDControl also looks interesting if sorting is the extent of what you want
to do, but I haven't had a chance to play with it.
Jonathan
_______________________________________________
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.