Skip to content

Instantly share code, notes, and snippets.

@aurels
Created November 8, 2010 11:00
Show Gist options
  • Select an option

  • Save aurels/667585 to your computer and use it in GitHub Desktop.

Select an option

Save aurels/667585 to your computer and use it in GitHub Desktop.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSLog(@"Deleting Task!");
Task *taskToRemove = [tasksArray objectAtIndex:indexPath.row];
//remove from taskArray
[tasksArray removeObjectAtIndex:indexPath.row];
//remove from core data and on server
[dm removeTask:taskToRemove];
//remove from UI
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if(editingStyle == UITableViewCellEditingStyleInsert) {
//load create task view
CreateTasksViewController *createTasksViewController = [[CreateTasksViewController alloc] initWithNibName:@"CreateTasksViewController" bundle:nil];
[createTasksViewController initWithDataManager:dm];
[self.navigationController pushViewController:createTasksViewController animated:YES];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment