Re: Subclassing dictionaries?
Re: Subclassing dictionaries?
- Subject: Re: Subclassing dictionaries?
- From: John Timmer <email@hidden>
- Date: Thu, 04 Sep 2003 08:47:46 -0400
>
Yes, you have to know what primitive methods NSDictionary class cluster
>
methods are expected to implement and implement those in your
>
subclasses.
>
>
You also need to take a step back and think about whether you *really*
>
need to subclass NSDictionary and NSMutableDictionary. What are you
>
really trying to accomplish by doing so? NSDictionary and
>
NSMutableDictionary are great generic containers.
>
>
-- Chris
The way I'm seeing it, the ideal tableView data source has a mutable array
of dictionaries. Look up the rowIndex, pass in the column ID as a key, get
out your object. Dead easy, but makes sorting them a hassle.
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.
It'll make all the code outside of my subclass much easier to implement and
read.
Maybe I'm missing some other good design idea that would accomplish the same
thing. If so, I'd love to hear it.
Cheers,
JT
--
"Microsoft does however have the power to make fundamentally dumb ideas into
industry standards, and that's clearly a worry." - The Register
_______________________________________________
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.