Re: Sorting array of NSDictionaries sortedArrayUsingFunction
Re: Sorting array of NSDictionaries sortedArrayUsingFunction
- Subject: Re: Sorting array of NSDictionaries sortedArrayUsingFunction
- From: Fritz Anderson <email@hidden>
- Date: Tue, 13 Jun 2006 16:47:49 -0500
On 13 Jun 2006, at 4:31 PM, David Alter wrote:
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.
I call your attention to this line in the example you supplied:
NSArray * sortedItems = [unsortedItems
sortedArrayUsingFunction:orderByName context:nil];
This is the line at which the error was raised. You think
unsortedItems refers to an NSArray; the running code thinks it refers
to an NSDictionary, and the running code, by definition, is right.
Two things are possible:
1. You inadvertently set sortedItems to an NSDictionary.
2. sortedItems started out as a reference to an NSArray, but the
array was released and deallocated, and by the time you get to the
line above, the pointer has been reused for an NSDictionary.
1 is fairly easy to audit, and a few minutes with the debugger should
show you the problem. 2 requires you to audit the releases on the
NSArray; Google NSZombieEnabled for help in doing that.
-- F
--
Fritz Anderson -- http://www.manoverboard.org/
Consulting Programmer -- http://resume.manoverboard.org/
Step into Xcode: You wouldn't want your bathroom copy in the kitchen!
-- 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