I am trying to follow this Ray Wenderlich tutorial that lets you rearrange tablecells where the datasource is an NSArray:
It uses the exchangeObjectAtIndexPath.row withObjectAtIndex:sourceIndexPath.row
method to rearrange the data behind the tableview. Since the data is held in a mutable array, it applies this method to self.dataItems, the NSMutableArray
holding the data as follows:
NSMutableArray * data = [@[@"Get Milk!", @"Go to gym", @"Breakfast with Rita!", @"Call Bob", @"Pick up newspaper", @"Send an email to Joe", @"Read this tutorial!", @"Pick up flowers"] mutableCopy];
self.dataItems = data;
// ... update data source.
[self.dataItems exchangeObjectAtIndex:indexPath.row withObjectAtIndex:sourceIndexPath.row];
In my case, I use a FetchedResultsController
to pull the data from coredata and the datasource for the tableView is self.
self.tableView.dataSource = self;
Does anyone know if there is something analagous to an NSArray behind the FRC so that I can implement the same method or otherwise swap the dataItems around while still using an FRC?
Thanks for any suggestions.