Join Todd Perkins for an in-depth discussion in this video Understanding class structure for this app, part of iOS App Development: Apple iCloud API (2013).
Before we start running the code for our app, I wanted to go over the basic classes and files that we're going to be working with, so you have an idea about how the app is organized before you create it. This is actually the finished version of the app, and for those of you who have access to the Exercise Files, I didn't provide files for this movie, because I just want you to watch and just look on the screen here. And I'm at MainStoryboard.storyboard, and this application is a storyboard application that's based on the master detail template.
And so it's going to be a note-taking app, and in a storyboard you will see that there is a Master view with a table view in it called Notes, and then the detail view has the text in it. So you create a note by clicking the plus button, the View with the Table view, and then you click on the note, and you see the note in a single Note view page. All the data is managed in the data class, and there are constant values in Constants.h. The data class has a number of methods that allow you to manipulate the data that's stored inside of an NSMutableDictionary.
Again the MasterViewController controls the Main View, which has the table view, and the DetailViewController controls the view when you're looking at a single Note. The finished application will allow you to create notes by clicking the plus button. After you create a note you can go back and see that the note is saved. You can click on the note to see and edit it.
Notes are then saved to user defaults, which means they are saved on your device until you delete the application. So if I click the Home button and the Stop button and run the application again, we'll see that that same note that I added is there along with the other notes that were there from before. So that's an overview of the classes we'll be working with in this chapter. This organization is called the ModelViewController design pattern. The Model represents the data for your app, which is stored in our data class.
The View is the visual part of your app, which is our storyboard. And Controller is the part of the app that contains the logic for manipulating the model to update the view. And that's split up into the MasterViewController and DetailViewController classes. So now that you've seen an overview of how this app is set up, let's start building it.
- Understanding the class structure of an app
- Building the data model and constants
- Making your app compatible with the Apple Developer portal
- Connecting to iCloud
- Understanding the UIDocument class
- Handling document metadata class
- Opening, closing, saving, and deleting documents from iCloud