In the case when you use a custom cell type, say ArticleCell, you may receive an error message:
Initializer for conditional binding must have Optional type, not 'ArticleCell'
You will get this error if your line of code looks something like this:
if let cell = tableView.dequeReusableCell(withIdentifier: "ArticleCell",for indexPath: indexPath) as! ArticleCell
You can fix this error by following these steps:
if let cell = tableView.dequeReusableCell(withIdentifier: "ArticleCell",for indexPath: indexPath) as ArticleCell?
If you check the above, you will see that the latter uses optional casting for a cell of type ArticleCell.
Lehlohonolo_Isaac Nov 01 '17 at 9:08 on 2017-11-01 09:08
source share