Skip to content

Instantly share code, notes, and snippets.

@benjaminsnorris
Created November 17, 2014 23:42
Show Gist options
  • Save benjaminsnorris/ab22ada42ba5dddc29c2 to your computer and use it in GitHub Desktop.
Save benjaminsnorris/ab22ada42ba5dddc29c2 to your computer and use it in GitHub Desktop.
Edit Actions for Table View Row
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *removeButton = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Remove" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
[self deletePlayerAtIndexPath:indexPath];
self.game.startingNumberOfPlayers = @(self.game.startingNumberOfPlayers.integerValue - 1);
}];
UITableViewRowAction *resetScoreButton = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Reset Score" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
[self.game resetScoresForPlayer:[self.fetchedResultsControllerDataSource.fetchedResultsController objectAtIndexPath:indexPath]];
}];
resetScoreButton.backgroundColor = [UIColor primaryColorLight];
return @[removeButton,resetScoreButton];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment