title: CollectionView inside another CollectionViewCell
body: <p>I am trying to create <code>collectionView</code> inside another <code>collectionViewCell</code>. I can get the cell of outer <code>collectionView</code> however, compiler is not executing inner cell. How can I get both the cells?</p>
  
  <p>P.S I am new at this.</p>
  
  <p><strong>CollectionViewController Class:</strong></p>
  
  <pre><code>class CollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout{
  
  @IBOutlet var collectionView1: UICollectionView!
  
  var coll2 = CollectionViewCell()
  override func viewDidLoad() {
      super.viewDidLoad()
  }
  override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
  
     return 3
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: view.frame.width, height: 150)
  }
  
  override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)as! CollectionViewCell
      cell.backgroundColor = UIColor.black
  
      return cell
  
  }
  
  }
  </code></pre>
  
  <p><strong>CollectionViewCell CLass:</strong></p>
  
  <pre><code>class CollectionViewCell: UICollectionViewCell  {
  
  @IBOutlet var collectionView2: UICollectionView!
  
   func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return 1
   }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: collectionView2.frame.width, height: 150)
  }
  
   func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell1 = collectionView.dequeueReusableCell(withReuseIdentifier: "cell2", for: indexPath)as! CollectionViewCell2
  
      cell1.backgroundColor = UIColor.red
  
      return cell1
  
   }
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/xoGn7.png" rel="nofollow">enter image description here</a>
  }</p>