Created
September 4, 2014 17:48
-
-
Save sstadelman/a1d34a62dfcb6b8b9f8c to your computer and use it in GitHub Desktop.
Example of deleteEntity:withCompletion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
if (editingStyle == UITableViewCellEditingStyleDelete) { | |
id<SODataEntity> entity = self.sortedEntities[indexPath.row]; | |
NSMutableArray *arr = [NSMutableArray arrayWithArray:self.sortedEntities]; | |
[arr removeObjectAtIndex:indexPath.row]; | |
self.sortedEntities = arr; | |
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; | |
[[DataController shared] deleteEntity:entity withCompletion:^(BOOL success) { | |
[[DataController shared]fetchTravelAgencyEntitySet]; | |
/* Here, the developer knows the type of the SODataEntity, and the current ViewController. | |
It is possible that the end user has navigated away from this ViewController, but it is | |
still in the stack. So, by invoking the -fetchTravelAgencySet, the developer knows that | |
the model will be updated soon, and any views which are observing the result of that GET | |
on the model will have the fresh data. Otherwise, the other views would need to handle | |
the sequence of their refresh independently, and might not have the freshest information. */ | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment