Getting Data into Collection Views

In the previous chapter, you learned about the Model-View-Controller (MVC) design pattern and about collection views. You've also revisited the Explore and Restaurant List screens, and now you understand how the collection views in both screens work. At this point, though, both screens just display cells that do not contain any data. As shown in the app tour in Chapter 9, Setting Up the Basic Structure, the Explore screen should display a list of cuisines, and the Restaurant List screen should display a list of restaurants.

In this chapter, you're going to implement the model objects for the Explore screen so it will display a list of cuisines.

You'll start by learning about model objects that you will use. Next, you'll learn about property lists, and see how they are used to store cuisine data, and you'll create a Swift structure that can store cuisine instances. After that, you'll create a data manager class that reads data from the property list and populates an array of structures. This array of structures will then be used as the data source for the collection view in the Explore screen.

By the end of this chapter, you'll learn how property lists are used to store data, how to create model objects, how to create a data manager class that can load data from a property list into an array of model objects, how to configure view controllers to provide model objects to collection view, and how to configure collection views to display data on screen.

 The following topics will be covered:

  • Understanding model objects
  • Understanding .plist files
  • Creating a structure to represent a cuisine
  • Implementing a data manager class to read data from a .plist file
  • Displaying data in a collection view
..................Content has been hidden....................

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