In this recipe we will learn how to delete an item from a Table View, as well our core data model.
Following on from our previous recipe, we will learn how to delete a row from our Table View, and permanently remove this from our Core Data database.
To begin, follow these simple steps as outlined in the following order:
Open the
BooksViewController.m
implementation file from the Project Navigator window.Modify the
btnSortOrder:
method as shown in the following code snippet.#pragma mark method called when the user presses the Display Order button - (IBAction)btnSortOrder:(id)sender { if ([btnSortOrder.title isEqualToString:@"Sort Order"]){ self.tableView.editing = YES; [btnSortOrder setTitle:@"Done"]; } else if ([btnSortOrder.title isEqualToString:@"Done"]) { [btnSortOrder setTitle:@"Sort Order"]; self.tableView.editing = NO; } }
Next, create the following code sections, as specified in the code...