Hello,
I'm trying to sort an array, from a previous post I was pointed to an answer in this thread, http://stackoverflow.com/questions/1422840/sorting-an-array-of-doubles-or-cllocationdistance-values-on-the-iphone/1422881#1422881
Based of this my code is as follows:
NSArray *sortedArray = [listArray sortedArrayUsingFunction:intSort context:nil];
NSInteger intSort(id num1, id num2, void *dummy)
{
int v1 = [[num1 objectForKey:@"waypoint_order"] intValue];
int v2 = [[num2 objectForKey:@"waypoint_order"] intValue];
if (v1 < v2)
return NSOrderedAscending;
else if (v1 > v2)
return NSOrderedDescending;
else
return NSOrderedSame;
}
But its crashing on line int v1 = [[num1 objectForKey:@"waypoint_order"] intValue]; with 'objc_exception_throw'.
What am I doing wrong, I must be leaving out some functionality.
Regards, Stephen