Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.