James Gifford
James Gifford

Reputation: 53

How to change CustomCell when it ends display?

I want to change this code:

override func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {

}

like that:

override func tableView(tableView: UITableView, didEndDisplayingCell cell: CustomCell, forRowAtIndexPath indexPath: NSIndexPath) {

}

but I receive an error message. I need to change my CustomCell when it disappears. How can I handle this ?

Upvotes: 1

Views: 1399

Answers (1)

Aaron Brager
Aaron Brager

Reputation: 66252

Use the original method signature, and use optional casting to access CustomCell:

override func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
    if let cell = cell as? CustomCell {
        // do something with cell
    }
}

Upvotes: 5

Related Questions