views:

411

answers:

3

I have a UITableView that implements NSFetchedResultsControllerDelegate. When I tap a cell, I load another viewcontroller which allows me to edit an entity represented by the tablecells. When I'm done editing, it sends a message to the UITableViewController which does a [self.tableview reloadData];

My problem is that reloadData doesn't seem to resort the data after I've modified it. How do I do this. How do I get it to do so?

+1  A: 

Not clear what is that you are trying to do. However if you want cells to be in a different order for a table view you must sort its data source, so if first you want it in order 1 2 3, then in your data source they will be in that order, but next if you want them 2 1 3 then you must resort your data source to contain 2 1 3 in that order, it all depends on what you are returning in cellForRowAtIndexPath for each index path, the sample i gave is assuming y ou are using the row indexpath to index into an array that i s your data source..hope this helps

Daniel
To continue Daniel's thought here, "reloadData" does not mean the tableview will modify the data in anyway. It means the tableview will ask *you* for the data again. It's the responsibility of the datasource (which you write) to maintain the data.
Rob Napier
I have passed an array of NSSortDescriptors to the NSFetchedResultsController. When I call [self.tableView reloadData] it's not sorting the new or modified element.
check that the data source a rray has actually been modified...
Daniel
A: 

You can pass the NSSortDescriptor to the NSFetchedResultsController, but have you actually executed a fetch?

georryan
A: 

You need to save the changes using [NSManagedObjectContext -save:] and then your NSFetchedResultsController will pick up the change and notify the table view to update. You do not need to call -reloadData because it will be handled for you.

Make sure that your UITableViewController is the delegate for the NSFetchedResultsController so that it can handle the update.

Marcus S. Zarra