Skip to content

Instantly share code, notes, and snippets.

@yabenatti
Created November 12, 2017 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yabenatti/c1799e810b232908cdf2b8d9876818cf to your computer and use it in GitHub Desktop.
Save yabenatti/c1799e810b232908cdf2b8d9876818cf to your computer and use it in GitHub Desktop.
TableViewTutorial02
extension ViewController : UITableViewDataSource {
//1 - primeiro método obrigatório
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
//2 - segundo método obrigatório
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//3 - crie uma célula com o mesmo identificador de quando registramos a classe
let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath)
//4 - mude o texto na label padrão da célula
cell.textLabel?.text = "row: \(indexPath.row) and section: \(indexPath.section)"
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment