Created
May 19, 2012 16:59
-
-
Save ninthspace/2731503 to your computer and use it in GitHub Desktop.
Deleting tasks, with optional confirmation
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)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