• 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: how to simulate passing parameter with selector
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to simulate passing parameter with selector


  • Subject: Re: how to simulate passing parameter with selector
  • From: Peter Ammon <email@hidden>
  • Date: Wed, 13 Feb 2008 17:45:39 -0800


On Feb 13, 2008, at 12:51 PM, Daniel Child wrote:

Hi,

I am trying to work around the fact that you cannot pass parameter values with a selector. Here's what I'm trying to do.

I have a generic table (essentially a class with an array instance variable) filled with generic records (also a class containing an array instance variable). I want to be able to sort the table based on one of the fields in the generic record. Since the generic table holds an array of records, my instinct is to use sortUsingSelector: (SEL) s. The problem, of course, is that to set up compare methods, I need to know which field I'm sorting on, and that is only determined at runtime.

The NSSortDescriptor approach is fine. Another one is to use sortedArrayUsingFunction:context: which allows you to pass a context pointer which is received by the comparing function.


-Peter

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >how to simulate passing parameter with selector (From: Daniel Child <email@hidden>)

  • Prev by Date: Re: CoreData: Save password securly
  • Next by Date: Re: how to simulate passing parameter with selector
  • Previous by thread: Re: how to simulate passing parameter with selector
  • Next by thread: Disable Exposé didn't work in leopard
  • Index(es):
    • Date
    • Thread