Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android
by Jakob Iversen, Michael Eierman
Sort the Table
One of the features of MyContactList is to be able to sort the table by different criteria as specified on the Settings screen. The code changes to enable sorting are relatively minor because the Core Data framework handles the heavy lifting. You need to import Constants.h and then make changes to loadDataFromDatabase: in LMAContactsTableController.m, as shown in Listing 12.13.
Listing 12.13 Enable Sorting of the Table
- (void) loadDataFromDatabase{ //read settings to enable sorting NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; //1 NSString *sortField = [settings stringForKey:kSortField]; //2 bool sortAscending = [settings boolForKey:kSortDirectionAscending ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access