I currently have an object called Station defined as:
@interface RFStation : NSObject {
NSString *stationID;
NSString *callsign;
NSString *logo;
NSString *frequency;
@end
I also have an NSMutableArray containing a list of 'Station' objects. I need to have a method to sort these objects by the 'stationState' attribute.
I implemented this method:
NSComparisonResult compareCallSign(RFStation *firstStation, RFStation *secondStation, void *context) {
if ([firstStation.stationState compare:secondStation.stationState]){
return NSOrderedAscending;
}else{
return NSOrderedDescending;
}
}
and call it using:
[stationList sortedArrayUsingFunction:compareState context:nil];
[self.tableView reloadData]
(the data is loaded into a UITableViewController)
Can someone please tell me why my NSMutableArray is not getting sorted?