Understanding .plist files

Property lists were developed by Apple to store data structures or object states so that they may be transmitted or reconstituted later. They are commonly used to store preferences for applications. Property list files use the .plist filename extension, and hence are often referred to as .plist files. You will be using a .plist file containing cuisine data, ExploreData.plist, in your project.

You will need to download the code bundle for this book to get the ExploreData.plist file. After that you can use Xcode to view its contents. Do the following steps:

  1. If you have not yet done so, download the resource files and completed Xcode project for this from this link: https://github.com/PacktPublishing/iOS-13-Programming-for-Beginners
  2. Open the Chapter14 folder and look inside the resources folder to find ExploreData.plist. This file stores cuisine names and image filenames.
  3. Open the LetsEat project, right-click on the Explore folder in the Project navigator, and choose New Group.
  1. Rename the new group that you just added Model.
  2. Drag ExploreData.plist into this group.
  3. Make sure Copy items if needed is ticked and click Finish.

When you click on ExploreData.plist in the Project navigator, you'll see an array that contains dictionariesThis can be seen in the following screenshot:

Each dictionary has two elements. The first element has a key, name, and a value describing a type of cuisine. The second element has a key, image, and a value containing the filename of a cuisine image. All of the cuisine images are stored in the Assets.xcassets file in your project.

To use the data contained in ExploreData.plist, you'll need to create a structure to hold it in the app, and accessed later by ExploreViewController. You will make one in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.181.231