Property List Workshop 3: Add Content in The Plist File

Last week you added code in the AppDelegate class files to create three methods for interacting with the plist file’s data. You added code in the AppDelegate didFinishLaunchingWithOptions method to create a plist file called, glossary.plist in the application sandbox’s Documents directory.

Now, in this workshop, you’ll add code in the MasterViewController.m file’s viewDidLoad method to add content in the plist file. You will also add code in the file’s tableView control methods to make its view functional.

Ok, so you know what you’ll do in this workshop, so launch the PropertyListDemo project in Xcode. Click the MasterViewController.m file and add highlighted code in the viewDidLoad method.

Next, add this code in the tableView control’s dataSource methods.

Finally, add this code in the tableView control’s delegate method.

Once you are done entering code in the MasterViewController.m file, run the application. Once Xcode finish building the project, the MasterViewController’s user interface will look like the image shown in Figure 1. Clicking a row display that row’s word and definition in the textView control, as shown in the Figure 2.

plistdemo-fig00
Figure 1

This concludes Property List Workshop series. By developing the PropertyListDemo application in the series you learned the follow:

  • How to create a property list file in the application sandbox’s Documents directory
  • Add content in the property list file
  • Fetch content from the property list file and place it in an Objective-C NSMutableDictionary variable
  • Display the property list file’s content in a tableView control and a textView control