Implementing additional data manager methods

As you learned in Chapter 13, Getting started with MVC and Collection Views, a collection view needs to know how many cells to display and what to put in each cell. You will add two methods to ExploreDataManager that will provide the number of ExploreItem instances in the items array and return an ExploreItem instance at a specified array index. Click ExploreDataManager.swift in the Project navigator and add these two methods above the loadData() method:

func numberOfItems() -> Int {
return items.count
}

func explore(at index:IndexPath) -> ExploreItem {
return items[index.item]
}

The first method, numberOfItems(), will determine the number of cells to be displayed by the collection view. 

The second method, explore(at:), will return ExploreItem that corresponds to a cell's position in the collection view.

Now, you need to update the data source methods in ExploreViewController to display the correct number of exploreCell collection view cells in the collection view and to provide the cuisine name and image for each cell.

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

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