Passing user information to ExploreViewController

You can now sign in successfully and the user's information is in your app. To display the user's given name in ExploreViewController, you need to implement the prepare(for:) method in SignInViewController. This is so you can pass the user's given name to ExploreViewController and use it to set the value of the large label in headerView. Follow these steps to do so:

  1. Click on ExploreViewController.swift (inside the Explore folder) in the Project navigator.
  2. Add a property just below the class declaration:
var givenName:String?
  1. Modify collectionView(_:viewForSupplementaryElementOfKind:at:) so that it prints givenName to the Debug area, as follows:
func collectionView(_ collectionView: UICollectionView, ...

Get iOS 13 Programming for Beginners - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.