What is the best way to do this? I currently just sort ascending by using a sortDescriptor like so:
NSSortDescriptor *Descriptor = [[[NSSortDescriptor alloc] initWithKey:@"Name" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)] autorelease];
Now if I have a checkButton that is used to determine if the user wants to sort by descending or ascending, what is the best way to handle this? Do I check for the checkButton’s state before creating the sortDescriptor? And then if the user hits the checkButton again (create another sortDescriptor of the opposite type (ascending or descending), then run the method to show the data in the new sorted mode? Thanks.
I’d hook the button up to a function that creates your sort descriptor and fetches your results. This results in a fetch being made each time the state is altered.
Pick a default, use this as the default sort type without any user-interaction, and then users can change their preference with the button.
I hope you find this handy!