title: Multiple cells for a single UICollectionView
body: <p>In my collection view, the cell class must have completely different appearance for different kinds of data in the array.</p>
  
  <p>I am looking for a way to create multiple cells and choose a different one according to the input data, so for example :</p>
  
  <pre><code>internal func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell1 = collectionView.dequeueReusableCell..  as! kind1
      let cell2 = collectionView.dequeueReusableCell.. as! kind2
     // here choose a different one for each kind of data
      return cell1
  }
  </code></pre>
  
  <p>I am trying to understand if :</p>
  
  <ol>
  <li>How to do this and if its the right way in terms of memory ?</li>
  <li>Is it a good design? how would you go about making a completely different layout of a single cell? ( creating views and hiding them seems like a bad approach)</li>
  </ol>