• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Subclassing dictionaries?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Subclassing dictionaries?
      • From: Wade Tregaskis <email@hidden>
    • RE: Subclassing dictionaries?
      • From: "Jonathan E. Jackel" <email@hidden>
    • Re: Subclassing dictionaries?
      • From: Chris Hanson <email@hidden>
References: 
 >Re: Subclassing dictionaries? (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Sending email with attachments
  • Next by Date: Split Buttons: How do I make em?
  • Previous by thread: Re: Subclassing dictionaries?
  • Next by thread: Re: Subclassing dictionaries?
  • Index(es):
    • Date
    • Thread