Re: Sorting array : segmentation fault
Re: Sorting array : segmentation fault
- Subject: Re: Sorting array : segmentation fault
- From: Ben Dougall <email@hidden>
- Date: Mon, 18 Aug 2003 21:13:20 +0100
On Monday, August 18, 2003, at 08:39 pm, kubernan @ 10191 Tec. wrote:
Hello,
I tried to sort an array of dictionaries, but it crashes on
segmentation fault.
Can you help me ?
static int _compareKeys(id left, id right, void *ctxt) {
if ([[left objectForKey:(NSString *)ctxt] doubleValue] < [[right
objectForKey:(NSString *)ctxt] doubleValue])
return NSOrderedAscending;
else if ([[left objectForKey:(NSString *)ctxt] doubleValue] >
[[right objectForKey:(NSString *)ctxt] doubleValue])
return NSOrderedDescending;
else
return NSOrderedSame;
}
implentation :
NSMutableArray *sortedArray;
sortedArray = [tempArray sortUsingFunction:_compareKeys
context:attribute];
sortUsingFunction:'s return type is void. i think you're after this
method instead:
- (NSArray *)sortedArrayUsingFunction:(int (*)(id, id, void
*))comparator context:(void *)context
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.