We will be showing a list of restaurants just like in our app, but we will not be doing the entire interface. Most of this code will be familiar to you as we have done it before.
- Open up the
MessagesViewController.swift
file in the Navigator panel and add the following code inside of the class declaration:
@IBOutlet var collectionView: UICollectionView! let manager = RestaurantDataManager() var selectedRestaurant:RestaurantItem?
- Next, we need to set up our Collection View defaults. Add the following method inside of a
private
extension:
private extension MessagesViewController { func setupCollectionView() { let flow = UICollectionViewFlowLayout() flow.sectionInset = UIEdgeInsets(top: 7, left: 7, bottom: 7, right: 7) flow.minimumInteritemSpacing = 0 flow.minimumLineSpacing = 7 collectionView.collectionViewLayout = flow collectionView.delegate = self collectionView.dataSource = self } }
You will see errors once...