Skip to content

Instantly share code, notes, and snippets.

@ninthspace
Created May 19, 2012 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninthspace/2731503 to your computer and use it in GitHub Desktop.
Save ninthspace/2731503 to your computer and use it in GitHub Desktop.
Deleting tasks, with optional confirmation
- (void)deleteCompletedTasksWithConfirmation:(id)sender {
if ([[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%d", AlistoPrefKeyConfirmDeletion]]) {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Delete completed tasks?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete tasks" otherButtonTitles:nil];
[sheet showFromToolbar:[[self navigationController] toolbar]];
} else {
[self deleteCompletedTasks];
}
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[self deleteCompletedTasks];
}
}
- (void)deleteCompletedTasks {
// item in this case is the actual List displayed by this view controller, so this is a method which deletes all completed tasks from the List
[item deleteCompletedTasks];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment