Skip to content

Instantly share code, notes, and snippets.

@Quaggie
Created March 14, 2018 17:26
Show Gist options
  • Save Quaggie/598ebbc60cc652ef1c2f23af4db3db35 to your computer and use it in GitHub Desktop.
Save Quaggie/598ebbc60cc652ef1c2f23af4db3db35 to your computer and use it in GitHub Desktop.
// No MotorcycleTableViewCell
class MotorcycleTableViewCell: UITableViewCell {
static var height: CGFloat {
return 80
}
static var identifier: String {
return String(describing: self)
}
// ---------------------------
// No ViewController
// Na criação do TableView
tableview.register(MotorcycleTableViewCell.self, forCellReuseIdentifier: MotorcycleTableViewCell.identifier)
// [...]
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let motorcycle = motorcycles[indexPath.row]
let cell = tableview.dequeueReusableCell(withIdentifier: MotorcycleTableViewCell.identifier, for: indexPath) as! MotorcycleTableViewCell
cell.motorcycle = motorcycle
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return MotorcycleTableViewCell.height
}
// [...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment