In this chapter, we’ll start making the iOS app feel more like an actual app: we’ll add the ability to open notes and view their contents, as well as the ability to edit and save changes to notes.
Along the way, we’ll create and connect up more new view controllers, create another new UI, and set up a segue to move between the list of notes and the note contents. We’ll also use
UITextViewDelegate to update the note document when the note text changes.
At the moment, the app has got the basics of note storage, but we don’t have any ability to actually view or edit our notes on iOS. To add this, we’ll create a view controller that lets you see and modify the content of note documents:
Open the File menu and choose New→File.
Ensure “Also create XIB file” is unchecked; we’ll be using the storyboard we already have set up.
Select Cocoa Touch Class and click Next.
Name the new class
DocumentViewController, and make it a subclass of
UIViewController. This will be responsible for the displaying the note, and eventually letting us edit the contents of notes.
Go to the Object library and drag a new view controller into the canvas.
Select the new view controller, open the Identity Inspector, and set its class to
DocumentViewController (see Figure 9-1). This connects the view controller in the storyboard to the view controller class that we just created.