Skip to content

Instantly share code, notes, and snippets.

@DominikPetho
Created October 1, 2018 11:11
Show Gist options
  • Save DominikPetho/f4f8ae2e2191c3111118e2b33bce1600 to your computer and use it in GitHub Desktop.
Save DominikPetho/f4f8ae2e2191c3111118e2b33bce1600 to your computer and use it in GitHub Desktop.
Disatvantage method
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var dequeuedCell: UITableViewCell?
if peopleWithAdvertisementList[indexPath.row] is Advertisement {
dequeuedCell = tableView.dequeueReusableCell(withIdentifier: "AdvertisementCell")
} else if peopleWithAdvertisementList[indexPath.row] is Person {
dequeuedCell = tableView.dequeueReusableCell(withIdentifier: "PeopleCell")
} else {
// Else what? Do we have other type comforming to SimpleViewCellItem protocol?
}
return dequeuedCell ?? UITableViewCell()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment