Reusable v2.2.0 Release Notes
-
This parameter is only needed if you can't write
… as MyCell
(to let Swift infer the cell type from the return type), which might be the case for example when your cell class is stored in a variable:let cellType: Any.Type = self.cellTypeForIndexPath(indexPath) // Can't do this in this case (because cellType is a variable): let cell = tableView.dequeueReusableCell(indexPath: indexPath) as cellType ❌ // compiler error // But now we can use that alternate way for such cases: let cell = tableView.dequeueReusableCell(indexPath: indexPath, cellType: cellType)
But if you know the type at compile time, you can omit the
cellType
parameter and still do this, letting the return type infer it for you:let cell = tableView.dequeueReusableCell(indexPath: indexPath) as MyCell