• 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 : segmentation fault
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • [Solved] Re: Sorting array : segmentation fault
      • From: "kubernan @ 10191 Tec." <email@hidden>
References: 
 >Sorting array : segmentation fault (From: "kubernan @ 10191 Tec." <email@hidden>)

  • Prev by Date: Re: Table view
  • Next by Date: Re: Table view
  • Previous by thread: Sorting array : segmentation fault
  • Next by thread: [Solved] Re: Sorting array : segmentation fault
  • Index(es):
    • Date
    • Thread