I have defined a class named c1 for a prototype cell like follows:
defined the code for c1 like this:
class c1 : UITableViewCell {
public func configure(indexPath: IndexPath) -> Self {
let place = places[indexPath.row]
self.textLabel?.text = place.name
self.detailTextLabel?.text = "\(place.timestamp)"
return self
}
}
* don't worry about undefined "places" so far
Inside the
UITableViewController
following code:override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell1", for: indexPath)
// Configure the cell...
return cell.configure(indexPath: indexPath);
}
But this doesn't work because obv. the compiler doesn't know about c1: "Value of type '
UITableViewCell
' has no member 'configure
'" at line 6.I think: Because the dequeReusableCell() asks for a specified identifier "Cell1" which in turn has to be implemented by the custom class "c1" which is also specified in the storyboard. So the xcode editor has to accept the cells type according the custom class and shouldn't throw a compiler issue regarding the unknown ".configure" method.