Join Todd Perkins for an in-depth discussion in this video Editing, saving, and deleting notes, part of Building a Note-Taking App for iOS 8.
- Let's finish our App, by adding…the ability to edit and save our notes.…So I'm in "DetailViewController.swift"…and I'm going to put my cursor right…below "viewDidLoad()" and I'm going…to start to type "viewWillDisappear" and once…it's highlighted in my code hinting window,…I'll press return on my keyboard and…Xcode will automatically add override…and func and everything else.…So this method, as you would guess, is called…right before we dismiss the detail view and return back…to the master view controller.…
So in here the first thing I'm going to do…is called "super.viewWillDisappear"…passing in the "animated" value.…Then what we want to do is make sure…that the user types in text in the text field.…If they type the text, then we want to save the note.…If they didn't type any text in the text field…and they clicked to go back to the master view,…then we don't want to save the note, we want to delete it.…So we'll use an if statement.…We'll check to see if "tView.text"…is equal to an empty string.…
If so, we don't want to save the note.…
Each of these courses helps you build 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 with iOS 8, and compare your results with the Android and Windows Phone courses to learn about the differences and similarities of these mobile 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 or user defaults
- Understanding screens and storyboards
- Controlling transitions between views
- Connecting the controller to the data
- Creating, editing, and deleting notes