title: Swift 4: Xib with collection view that reuse cell from storyboard, inner outlets are nils
body: <p>I have a cell that was used in main storyboard collection view:</p>
  
  <pre><code>class TaskCell: UICollectionViewCell {
  
      @IBOutlet weak var exerciseTitle: UILabel!
  
  
      override func awakeFromNib() {
          super.awakeFromNib()
          self.layer.borderWidth = 1
          self.layer.borderColor = #colorLiteral(red: 0.6666666865, green: 0.6666666865, blue: 0.6666666865, alpha: 1)
      }
  
  }
  </code></pre>
  
  <p>I created a XIB with collection view inside and I am trying to use this cell inside XIB`s collection view. The cell is dequeued, <strong>but all outlets inside it are nils</strong>.</p>
  
  <pre><code>class AddTaskToSessionVC: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
  
      @IBOutlet weak var collectionView: UICollectionView!      
      public var allTasks = [TaskCodableEntity]()
  
      override func awakeFromNib() {
          super.awakeFromNib()    
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
          self.collectionView.delegate = self
          self.collectionView.dataSource = self           
          self.collectionView.register(TaskCell.self, forCellWithReuseIdentifier: "TaskCell")
          self.getCurrentPatientTasks()
  
          // Do any additional setup after loading the view.
      }
  
      public func getCurrentPatientTasks() {
  
         self.allTasks =  API.getTasks()
          }
      }
  
      func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
          return self.collectionView.showNoDataLabel(array: self.allTasks)
      }
  
      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          return self.allTasks.count
      }
  
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
          if let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "TaskCell", for: indexPath) as? TaskCell {
              let taskEntity = self.allTasks[indexPath.row] 
                  cell.exerciseTitle.text = taskEntity.title
              ***(Here exerciseTitle is nil)***
  
              return cell
          }
          return UICollectionViewCell()
      }
  }
  </code></pre>
  
  <p>My XIB is look like:</p>
  
  <p><a href="https://i.stack.imgur.com/HFJVZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HFJVZ.png" alt="enter image description here"></a></p>
  
  <p>I tried to instantiate label inside cell, but it still stay as nil
  Is there is a way to reuse cells in such way or I should create XIB cell despite of already exists cell?</p>