I can't figure how to sort data in UITableView alphabetically.
I've been using the ToDoList sample in Icodeblog (Website). Once I enter the data it appears on the UITableview. The data is located in a sqlite file.
I created a button in the UITableview bar to run this code to sort the text alphabetically... but it doesn't work:
NSMutableArray *array = [NSMutableArray array];
NSArray *sortedArray;
NSSortDescriptor *lastDescriptor =
[[NSSortDescriptor alloc] initWithKey:newTodo.text
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)];
NSArray *descriptors = [NSArray arrayWithObjects:lastDescriptor, nil];
sortedArray = [array sortedArrayUsingDescriptors:descriptors];
[self.tableView reloadData];
Please point me to the right direction. My friend also told me to check "sortUsingSelector" method ... but I still can't figure it out.
The sample code that I'm using is located here.