I’ve got a NSArray with a bunch of EKCalendar Objects in it. I need to sort them alphabetically. I’m new to selectors but I think I need something like…
NSArray *array = [otherArray sortedArrayUsingSelector:@selector('localizedCaseInsensitiveCompare:title')];
Cheers
You cannot do it that way. Instead do the following:
Edit – an explanation:
-sortedArrayUsingComparatortakes what is called a ‘block’ (an inline function) that must return anNSComparisonResult. All the hard work is done for you, as your block is run for as many pairs of objects as is needed to establish the correct order. Then all this does is cast each object type to anEKCalendarand then compare the two titles. You can adapt this to work for any type of object.