title: Reload CollectionView with different cells
body: <p>I'm a beginner in swift and want to create my first apps. In the app I use collectionViews because I follow the advise from Lets build that App on Youtube.<br>
  In my App I want to have a vertical collectionView. In this collectionView I want another collectionView that consists of 2 different cells: 1x TitleCell and ?x ContentCell.<br>
  For these cells an API-Request is send to set their values. After the API-Call is done I reload the collectionView with:  </p>
  
  <pre><code>  self.collectionView.reloadData()  
  </code></pre>
  
  <p>Unfortunately when I reload the data my TitleCell gets overwritten by the ContentCell. As I have read in the swift docs about reloadData(): when its called it erases each cell and replaces it with the last called cell: In my case the ContentCell.  </p>
  
  <p>Therefore my question is, is there are way to reload the TitleCell and ContentCell in a way that they don't get overwritten?<br>
  And also: is it a bad practice to make a collectionView with 2 different cells?   </p>
  
  <p><strong>Here is my Code:</strong>   </p>
  
  <p>API:  </p>
  
  <pre><code>class ApiService: NSObject {
   static let sharedInstance = ApiService()
  
   var contentBaseUrl = "netAddress"
  
    func fetchContent(from url: String, completion: @escaping ([ContentModel]) -&gt; ()) {
      fetchFeedForUrlString(urlString: "\(contentBaseUrl)/"folder"/\(url)", completion: completion)
   }
  
   func fetchFeedForUrlString&lt;T: Decodable&gt;(urlString: String, completion: @escaping (T) -&gt; ()) {
      let url = URL(string: urlString)
      let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in
  
          guard let data = data else {
              return
          }
  
          do {
              let json = try JSONDecoder().decode(T.self, from: data)
  
              DispatchQueue.main.async {
                  completion(json)
              }
  
          } catch let jsonError {
              print(jsonError)
          }
  
      }
  
      task.resume()
   }
  }
  </code></pre>
  
  <p>CollectionView that calls api:  </p>
  
  <pre><code>class VHomeCell: BaseCell, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
  
  var firstCell = true
  var content: [ContentModel]?
  
  override func setupViews() {
      super.setupViews()
  
      fetchVideos()
      collectionView.register(HomeContentCell.self, forCellWithReuseIdentifier: "ContentCellID")
      collectionView.register(LeagueCell.self, forCellWithReuseIdentifier: "TitleCellID")
  }
  
  //Method that causes the "error"
  func fetchMatches() {
  
      ApiService.sharedInstance.fetchData(from: "ApiNetworkAddress", completion: { (content: [ContentModel]) in
          self.content = content
          self.collectionView.reloadData()
      })
  }
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return content?.count ?? 0
  }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      if firstCell {
          firstCell = false
          let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TitleCellID", for: indexPath) as! TitleCell
          return cell
      } else {
          let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ContentCellID", for: indexPath) as! ContentCell
          cell.match = matches?[indexPath.item]
          return cell
      }
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: frame.width, height: 50)
  }
  </code></pre>
  
  <p>ContentCell and TitleCell are just 2 UICollectionView Cells with different content in them:  </p>
  
  <pre><code> class TitleCell: BaseCell {
     var content: ContentModel? {
        didSet {
          title.text = content.titleText
       }
    }
   }
  
   class ContentCell: BaseCell {
     var content: ContentModel? {
        didSet {
           content.Text = content.text
       }
    }
   }
  </code></pre>
  
  <p>Here is the used BaseCell:   </p>
  
  <pre><code>class BaseCell: UICollectionViewCell {
    override init(frame: CGRect) {
      super.init(frame: frame)
      setupViews()
    }
  
  func setupViews() {
  
  }
  
  required init?(coder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
  }
  }
  </code></pre>
  
  <p>I'm aware my code needs a lot of cleaning and stuff. Therefore, I'm happy if some could also point out how I can clean my code or make it more efficient. </p>