Our Explore has a header, and we need to pass data over to it. To do that, we need to create a header class for it:
- Right-click on the View folder inside of Explore folder and select New File.
- On the Choose a template for your new file screen, select iOS at the top. Then, select Cocoa Touch Class. Then, hit Next.
- In the options screen that appears, add the following:
New file:
-
- Class: ExploreHeaderView
- Subclass: UICollectionReusableView
- Also create XIB: Unchecked
- Language: Swift
- Click Next and then Create.
- Add the following to this file:
import UIKit
class ExploreHeaderView: UICollectionReusableView {
@IBOutlet weak var lblLocation:UILabel!
}
- Next, open the Explore.storyboard file and under the Identity inspector in the Utilities Panel, update the Class to ExploreHeaderView.
Now, let's work on passing data from a location to explore and display the selected location in our header.