Skip to content

Instantly share code, notes, and snippets.

@clc80
Last active January 30, 2020 02:53
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 clc80/a82bf02bc5f97a11c40821c9d894cf85 to your computer and use it in GitHub Desktop.
Save clc80/a82bf02bc5f97a11c40821c9d894cf85 to your computer and use it in GitHub Desktop.
UINameTableViewController
import UIKit
var names = ["Harry Potter", "Hermoine Granger", "Ron Weasley", "Albus Dumbledore", "Draco Malfoy"]
class NameTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return names.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "NameCell", for: indexPath)
let name = names[indexPath.row]
cell.textLabel?.text = name
return cell
}
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment