title: Error - Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:]
body: <p>I have two collection views.  the first collection view without second collection view work fine. I don't know where is the problem in second collection view.</p>
  
  <p>first collection view: <code>collection_options</code>
  second collection view: <code>collection_contactus</code></p>
  
  <p>I got this error :</p>
  
  <pre><code>Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UICollectionView.m:4971
  2017-03-07 21:43:14.188 kashanmap[32788:427373] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier cellContentAJob - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
  </code></pre>
  
  <p>all of my class:</p>
  
  <pre><code>class ContentAJobViewController: UIViewController , UICollectionViewDataSource, UICollectionViewDelegate{
  
      @IBOutlet weak var image_slider: ImageSlideshow!
      var job_id = "0"
      let db = DatabaseManager()
      var jobs = [GlobalHelper]()
      var job = GlobalHelper()
  
  
      @IBOutlet weak var label_title: UILabel!
  
      @IBOutlet weak var collection_options: UICollectionView!
  
      @IBOutlet weak var collection_contactus: UICollectionView!
  
  
      let reuseIdentifier             = "cellContentAJob"
      let reuseIdentifierContactUs    = "cell_content_a_job_contact_us"
  
      var item_options    = [String]()
      var item_contact_us = [GlobalHelper]()
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          initialValues()
      }
  
      func initialValues()
      {
          db.openDatabase()
  
          collection_options!.dataSource = self
          collection_options!.delegate = self
  
          collection_contactus!.dataSource = self
          collection_contactus!.delegate = self
  
  
          self.image_slider.contentScaleMode = UIViewContentMode.scaleAspectFill
          jobs = db.getContentAJob(id: job_id)
          job  = jobs[0]
  
          var arr_imgs = job.images.components(separatedBy: ",")
          var images = [InputSource]()
          for img in arr_imgs
          {
              let alamofireSource = AlamofireSource(urlString: img)!
              images.append(alamofireSource)
          }
  
  
          self.image_slider.setImageInputs(images)
  
          label_title.text = job.title
  
          self.image_slider.bringSubview(toFront:label_title)
  
  
          initialOptions()
          initialContactUs()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      func initialOptions()
      {
  
          self.image_slider.bringSubview(toFront:collection_options)
  
  
  
          if(self.job.wifi == "1")
          {
              self.item_options.append("wififree")
          }
  
          if(self.job.apple_health == "1")
          {
              self.item_options.append("sib_noghrei")
          }
          if(self.job.wc == "1")
          {
              self.item_options.append("wc")
          }
  
          if(self.job.full_time == "1")
          {
              self.item_options.append("fulltime")
  
          }
  
          if(self.job.pos == "1")
          {
              self.item_options.append("pos")
          }
  
          if(self.job.parking == "1")
          {
              self.item_options.append("parking")
          }
  
  
          DispatchQueue.main.async{
          self.collection_options.reloadData()
  
          }
  
  
      }
  
      func initialContactUs()
      {
          var phone       = GlobalHelper();
          var mobile      = GlobalHelper();
          var fax         = GlobalHelper();
          var web         = GlobalHelper();
          var email       = GlobalHelper();
          var hour_work   = GlobalHelper();
          var city        = GlobalHelper();
          var address     = GlobalHelper();
          var manager     = GlobalHelper();
  
          if(job.phone != "")
          {
              phone.images = "call_phone"
              phone.title = job.phone
              item_contact_us.append(phone)
          }
  
  
          if(job.mobile != "")
          {
              mobile.images = "call_mobile"
              mobile.title = job.mobile
              item_contact_us.append(phone)
          }
  
          if(job.fax != "")
          {
              fax.images = "fax"
              fax.title = job.mobile
              item_contact_us.append(fax)
          }
  
          if(job.website != "")
          {
              web.images = "network"
              web.title = job.website
              item_contact_us.append(web)
          }
  
          if(job.email != "email")
          {
              email.images = "email"
              email.title = job.email
              item_contact_us.append(email)
          }
  
          if(job.work_hours != "")
          {
              hour_work.images = "work_hours"
              hour_work.title = job.work_hours
              item_contact_us.append(hour_work)
          }
  
          if(job.city != "")
          {
              //city.images = ""
              address.title = job.city
              //item_contact_us.append(city)
          }
  
          if(job.address != "")
          {
              address.images = "address"
              address.title = job.address
              item_contact_us.append(address)
          }
  
          if(job.manager != "")
          {
              manager.images = "manager"
              manager.title = job.manager
              item_contact_us.append(manager)
          }
  
          DispatchQueue.main.async{
              self.collection_contactus.reloadData()
  
          }
  
  
      }
  
  
      /*
      // MARK: - Navigation
  
      // In a storyboard-based application, you will often want to do a little preparation before navigation
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          // Get the new view controller using segue.destinationViewController.
          // Pass the selected object to the new view controller.
      }
      */
  
  
  
  
  
  
  
      // MARK: - UICollectionViewDataSource protocol
  
      // tell the collection view how many cells to make
      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
  
          if(collectionView == collection_options)
          {
             return self.item_options.count
          }
  
          if(collectionView == collection_contactus)
          {
              return self.item_contact_us.count
          }
  
          return 0;
  
      }
  
      // make a cell for each cell index path
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
  
  
          var cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! CellContentAJobCollectionViewCell
  
          if(collectionView == collection_options)
          {
              cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! CellContentAJobCollectionViewCell
  
  
              let image_name = self.item_options[indexPath.row]
              cell.img_view_cell_options.image = UIImage(named: image_name as! String)
  
              return cell
          }
  
          if(collectionView == collection_contactus)
          {
  
              let cell1 = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifierContactUs, for: indexPath as IndexPath) as! CellContactUsCollectionViewCell
  
              let image_name = self.item_contact_us[indexPath.row].images
              cell1.img_view_cell_contact_us.image = UIImage(named: image_name as! String)
              cell1.label_view_cell_contact_us.text = self.item_contact_us[indexPath.row].title
  
              return cell1
          }
  
          return cell;
  
  
  
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>updated</strong></p>
  
  <p><a href="https://i.stack.imgur.com/otQp2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/otQp2.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p><strong>updated</strong></p>
  
  <p>I found the problem,
  when I comment <code>item_contact_us.append(obj)</code> 's everything work fine !</p>
  
  <p>why?</p>