Skip to content

Instantly share code, notes, and snippets.

@toast38coza
Created October 19, 2014 21:24
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 toast38coza/8e6ac406cd50e45765b5 to your computer and use it in GitHub Desktop.
Save toast38coza/8e6ac406cd50e45765b5 to your computer and use it in GitHub Desktop.
Show a list of items in a tableview
// Drag
// Add UITableViewDelegate delegage
// class ViewController: UIViewController, UITableViewDelegate {
let people = ["Jim", "Joe", "Bob", "Jane"]
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return people.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
cell.textLabel?.text = people[indexPath.row]
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment