|Sep 16, 2008, 02:46 AM||#1|
Sorting NSMutableArray of NSNumber objects
How would I sort a small NSMutableArray that has NSNumber objects. I want to arrange the array in ascending order so the smaller numbers are at the beginning of the array. I looked at the docs but there isn't much examples that are clear. Can someone provide an example?
|Sep 16, 2008, 03:06 AM||#2|
I kind of figured it out. I used
[myArray sortUsingSelector: @selector(compare];
but could someone explains what @selector means or does?
By the way this is not for a homework assignment.
|Sep 16, 2008, 03:11 AM||#3|
@selector gets a reference to the function/method that will be called to implement that selector name.
Sponsor me to cycle 100Km round London in the dark
|Sep 16, 2008, 10:11 AM||#4|
Assuming myArray is of type NSMutableArray
NSSortDescriptor *mySorter = [[NSSortDescriptor alloc] initWithKey:@"property_or_method_of_objects" ascending:YES]; [myArray sortUsingDescriptors:[NSArray arrayWithObject:mySorter];
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|nsmutablearray||tacotester1||iPhone/iPad Programming||6||Apr 10, 2014 04:18 PM|
|OpenGL ES: Vertex Buffer Objects and Vertex Array Objects||Blakeasd||iPhone/iPad Programming||2||Jul 12, 2013 11:24 PM|
|Objective-C help with NSMutableArray||dancks||Mac Programming||4||Apr 15, 2013 04:25 PM|
|Binding an NSNumber to an NSTableColumn||BadWolf13||Mac Programming||4||Dec 30, 2012 03:49 AM|
|How to select NSNumber data with NSPredicate??||mikezang||iPhone/iPad Programming||0||Oct 17, 2012 09:39 AM|
All times are GMT -5. The time now is 05:41 PM.