• 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
Sorting array of NSDictionaries sortedArrayUsingFunction
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sorting array of NSDictionaries sortedArrayUsingFunction


  • Subject: Sorting array of NSDictionaries sortedArrayUsingFunction
  • From: David Alter <email@hidden>
  • Date: Tue, 13 Jun 2006 12:01:01 -0700

I'm using sortedArrayUsingFunction to sort an array of NSDictionaries on a specific item in the dictionary. It is giving me an error of "selector not recognized". I thought that was the point of using a function, that way I was not dependant on a selector in the class.

here is what I have


@implementation MyClass

...

static int orderByName(id item1, id item2, void *context) {

//The item name is a NSString in the dictionary
return [[item1 objectForKey:@"name"] compare: [item2 objectForKey:@"name"]];

}



-(void) someMethedThatCallsTheSort { ...

NSArray * sortedItems = [unsortedItems sortedArrayUsingFunction:orderByName context:nil];
...
}


...
@end

Can someone please let me know what I'm missing here.

Thanks for the help
-dave

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Sorting array of NSDictionaries sortedArrayUsingFunction
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: sheets and drawers
  • Next by Date: dynamic GUI, how to?
  • Previous by thread: Re: sheets and drawers
  • Next by thread: Re: Sorting array of NSDictionaries sortedArrayUsingFunction
  • Index(es):
    • Date
    • Thread