|
|
#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?
|
|
|
|
0
|
|
|
#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. |
|
|
|
0
|
|
|
#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 |
|
|
|
0
|
|
|
#4 |
|
Assuming myArray is of type NSMutableArray
Code:
NSSortDescriptor *mySorter = [[NSSortDescriptor alloc] initWithKey:@"property_or_method_of_objects" ascending:YES]; [myArray sortUsingDescriptors:[NSArray arrayWithObject:mySorter]; |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| added objects to nsmutablearray, yet the array is null | johnmerlino | Mac Programming | 4 | Nov 11, 2011 10:50 PM |
| Trying to convert object to NSMutableArray | johnmerlino | iPhone/iPad Programming | 4 | Nov 11, 2011 03:08 AM |
| Regenerating NSFetchedResultsController to dynamically change sort descriptor of UITa | bicbac | iPhone/iPad Programming | 0 | Nov 4, 2010 03:55 AM |
| NSMutableArray of UIButton objects | XcodeNewb | iPhone/iPad Programming | 3 | Jul 29, 2009 11:20 PM |
| Storing NSMutableArray full of custom object into NSUserDefaults | playboy16 | iPhone/iPad Programming | 6 | Jun 29, 2009 12:00 PM |
All times are GMT -5. The time now is 11:33 PM.






];
Linear Mode

