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

Re: Sorting array of NSDictionaries sortedArrayUsingFunction


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

Sorry about that. Here is the details about the selector

2006-06-13 14:24:57.326 TestApp[2195] *** -[NSCFDictionary sortedArrayUsingFunction:context:]: selector not recognized [self = 0x52f5b0]
2006-06-13 14:24:57.327 TestApp[2195] An uncaught exception was raised
2006-06-13 14:24:57.327 TestApp[2195] *** -[NSCFDictionary sortedArrayUsingFunction:context:]: selector not recognized [self = 0x52f5b0]
2006-06-13 14:24:57.327 TestApp[2195] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSCFDictionary sortedArrayUsingFunction:context:]: selector not recognized [self = 0x52f5b0]



I'm guessing that it is looking for the selector in the NSDictionary. But the function that I'm using for the compare is not part of the NSDictionary class. This can be seen in the example I have in my original message.


thanks for the help
-dave



On Jun 13, 2006, at 2:16 PM, Fritz Anderson wrote:

On 13 Jun 2006, at 2:01 PM, David Alter wrote:

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.

The "selector not recognized" error should tell you what selector is not recognized, and, as I recall, the class of the object that didn't recognize it. Care to share?


	-- F


--
Fritz Anderson -- http://www.manoverboard.org/
Consulting Programmer -- http://resume.manoverboard.org/
Step into Xcode: All right, yes Fathers' Day, goes without saying. -- http://six.manoverboard.org/




_______________________________________________ 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>
    • Re: Sorting array of NSDictionaries sortedArrayUsingFunction
      • From: glenn andreas <email@hidden>
References: 
 >Sorting array of NSDictionaries sortedArrayUsingFunction (From: David Alter <email@hidden>)
 >Re: Sorting array of NSDictionaries sortedArrayUsingFunction (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: Sorting array of NSDictionaries sortedArrayUsingFunction
  • Next by Date: Re: Problems with NSURLRequest and HTTP POST Form Data
  • Previous by thread: Re: Sorting array of NSDictionaries sortedArrayUsingFunction
  • Next by thread: Re: Sorting array of NSDictionaries sortedArrayUsingFunction
  • Index(es):
    • Date
    • Thread