title: Setting a delegate for UITableView Cells
body: <p>I have this for my table view</p>
  
  <pre><code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      if let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? CurrentItemsCell {
          cell.isUserInteractionEnabled = true
          let responseItems = currentItemsArray[indexPath.row]
          cell.configureCell(currentItem: responseItems)
  
          cell.setNeedsLayout()
          return cell
      } else {
          return CurrentItemsCell()
      }
  
  }
  </code></pre>
  
  <p>Here is my cell stuff.</p>
  
  <pre><code>class CurrentItemsCell: UITableViewCell {
      ...
      weak var mDelegate:MyProtocolImage?
      ...
  }
  
  @IBAction func showImages(_ sender: Any) {
      guard let indexPath = indexPath else { return }
      mDelegate?.sendIndexPathBack(row: indexPath.row)
      print("FROM THE CELL CLASS")
  }
  
  protocol MyProtocolImage: class {
      func sendIndexPathBack(row: Int)
  }
  </code></pre>
  
  <p>Inside of the UITableView I tried to add cell.mDelagate = self but there is an error. </p>
  
  <pre><code>Cannot assign value of type 'ItemResultsViewController' to type 'MyProtocolImage?'
  </code></pre>
  
  <p>Which now if I do <code>cell.mDelegate = self as! MyProtocolImage</code>, the syntax is fine, but the app crashes. </p>
  
  <p>Basically, I have a button inside of each cell, I need to get the indexRow of the cell, so I can get the itemId of whatever item's button was pressed. I then have to send the itemId to a new ViewController (a modal) with a Seque.</p>
  
  <p>Any help would be awesome</p>