title: Reload data not working in HeaderView in Swift
body: <p>I am not able to update the data of the Header View of a <code>CollectionView</code>. This header view is a subclass of <code>UICollectionReusableView</code>.</p>
  
  <p>I tried to call a method for reloading this data in different places but none of them is triggering the update. To see the updated data I have to close and open the app again.</p>
  
  <p>Collection View:</p>
  
  <pre><code>    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -&gt; UICollectionReusableView {
  
          guard kind == UICollectionView.elementKindSectionHeader else {
              fatalError("Unexpected element kind.")
          }
  
          let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "ProfileHeaderView", for: indexPath) as! ProfileHeaderView
  
           header?.reloadData()
  //        headerView.userNameLabel.text = defaults.string(forKey: "username")
  
          return headerView
      }
  </code></pre>
  
  <p>Header View:</p>
  
  <pre><code>class ProfileHeaderView: UICollectionReusableView {
  
      @IBOutlet weak var userNameLabel: UILabel!
  
      func reloadData() {
  
          let defaults = UserDefaults.standard
          usernameTextLabel.text = defaults.string(forKey: "username")
  
      }
  </code></pre>
  
  <p>I also tried to call <code>reloadData()</code> on <code>ViewWillAppear</code> and <code>ViewDidAppear</code></p>