• 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: "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.

References: 
 >Re: Subclassing dictionaries? (From: John Timmer <email@hidden>)

  • Prev by Date: Re: Split Buttons: How do I make em?
  • Next by Date: Re: Generating Unique ID
  • Previous by thread: Re: Subclassing dictionaries?
  • Next by thread: Re: Subclassing dictionaries?
  • Index(es):
    • Date
    • Thread