title: Memory leaks when calls dequeueReusableCell(withIdentifier:for:) swift
body: <p>I have to show a couple of different cells. I called <code>tableView(_:cellForRowAt:)</code> for that, and in the method I use two different IDs for different classes of <code>UITableViceCell</code></p>
  
  <p>Here is a simple code:</p>
  
  <pre><code>class SimpleView: UITableViewController {
  ...
  
  let cellIdMain = "JournalMainCellID"
  let cellIdExtra = "JournalMainSceneAddNewID"
  
  ...
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      if indexPath.row == journals.count {
          guard let cellAdding = tableView.dequeueReusableCell(withIdentifier: cellIdExtra, for: indexPath) as? JournalMainSceneAddNew else {
              fatalError("Cannot connect to the cell")
          }
          return cellAdding
      }
  
      guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdMain, for: indexPath) as? JournalMainSceneCell else {
          fatalError("Cannot connect to the cell")
      }
      cell.numberOfCountriesLabel.text = "\(journals[indexPath.row].numberOFCountries)"
      return cell
  }
  }
  </code></pre>
  
  <p>When I tried to find memory leaks I found:</p>
  
  <p><a href="https://i.stack.imgur.com/6YpbN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6YpbN.png" alt="enter image description here"></a></p>
  
  <p>When I click on the details I found:</p>
  
  <p><a href="https://i.stack.imgur.com/ETtbv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ETtbv.png" alt="enter image description here"></a></p>
  
  <p>Why this happened? It looks pretty simple and straightforward.</p>
  
  <p>Updated: pictures were updated.</p>