Should I make delegate of custom cell as a weakly referenced proprety?
<p><strong>ViewController Code</strong>  </p>

<pre><code>class ViewController: UIViewController {
    deinit {
        print("ViewController deinitialised")
    }

    @IBOutlet weak var tableView: UITableView!

    override func viewDidLoad() {
        self.tableView.dataSource = self
    }

    func didTapBlue() {

    }
}

extension ViewController: UITableViewDataSource, CustomCellDelegate {
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
        return 5
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("myCell") as! CustomCell
        cell.delegate =  self
        cell.textLabel!.text = "\(indexPath.row)"
        return cell
    }

    func buttonTapped() {
        print("Button tapped")
    }
}
</code></pre>

<p><strong>CustomCell Code</strong></p>

<pre><code>class CustomCell: UITableViewCell {
    deinit {
        print("Cell deinitialised")
    }

    var delegate: CustomCellDelegate! //When protocol Type is A
    // weak prefix when protocol Type is B
    // weak var delegate: CustomCellDelegate!

    @IBAction func buttonClickAction(sender: AnyObject) {
        if let del = self.delegate {
            del.buttonTapped()
        }
    }
}
</code></pre>

<p><strong>Protocol Type A</strong></p>

<pre><code>protocol CustomCellDelegate{
    func buttonTapped()
}
</code></pre>

<p><strong>Protocol Type B</strong></p>

<pre><code>protocol CustomCellDelegate: class {
    func buttonTapped()
}
</code></pre>

<p>I am confused about what is the appropriate way to implement delegate pattern for passing message between Cell And ViewController. I know that if two objects hold each other's reference strongly, there will be a retain cycle and they won't get deallocated in the application lifetime.</p>

<p>In the above code, ViewController doesn't seem to hold reference of Cell. Hence I think it doesn't matter if I use protocol of type A and keep the strong reference of ViewController in cell.</p>

<p>But will my code be any safer if I declare the delegate property as a weakly referenced property? What are the implications of it?</p>

<p><strong>Update:</strong></p>

<p>Turns out that even if the ViewController is not holding direct reference of cell &amp; even if TableView's reference is weak, ViewController is somehow holding strong reference to the cells. When I follow Method A, that is without declaring the delegate to be of weak reference. The deinit methods in Cell and ViewController never gets called. I checked in instruments too. The persistent retain count keeps increasing if I don't declare delegate as weak.</p>

<p><a href="https://i.stack.imgur.com/c1Pnc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c1Pnc.png" alt="enter image description here"></a></p>

<p><strong>Now the big question is how is ViewController holding strong reference to the cells?</strong></p>