Join Todd Perkins for an in-depth discussion in this video Deleting notes, part of Building a Note-Taking App for iOS 7.
- View Offline
…Now let's finish our application by deleting objects.…What we want to do is make it so when you click the edit button, you can remove…objects from the table and they are deleted…both from the table and from your saved data.…So find the method,…tableView commitEditingStyle, forRowAtIndexPath in MasterViewController.…Add an if statement above _objects removeObjectAtIndex.…We're going to remove the object from the data model.…
So Data, removeNoteForKey, and the key is going to come from _objects.…So, in brackets, _objects objectAtIndex, and…the index is going to be indexPath.row.…That will grab the appropriate key we need to remove.…Now we want to save all the notes.…So Data, saveNotes.…So once we've deleted the key, we want to save the…notes and we're already removing that from the object's array.…
And then we're already removing that from the table as well.…So that's really all we need to do.…So if I test the application, and I want to delete Note…3, I can click the edit button, the minus button, and then delete.…
These courses take you through building a complete mobile app from scratch; this installment uses the iOS SDK and Xcode to get the job done. Author Todd Perkins shows you how to create an Xcode project, lay out apps visually, connect UI elements to code, and save data to persistent storage. Start here, and compare and contrast your results with the other courses to learn about the differences and similarities of the platforms.
- Previewing the note-taking app's features
- Creating the Xcode project
- Using local data storage
- Creating a data class
- Saving data to a file
- Understanding screens and storyboards
- Creating and editing notes
- Controlling note display in a table view
- Deleting notes