Skip to content

Instantly share code, notes, and snippets.

@chug2k
Created January 28, 2015 23:40
Show Gist options
  • Save chug2k/b6f6f59317c623efadeb to your computer and use it in GitHub Desktop.
Save chug2k/b6f6f59317c623efadeb to your computer and use it in GitHub Desktop.
// Simplest possible TableView.
import Foundation
class SimpleTableViewController: UITableViewController {
let data = ["foo", "bar", "baz"]
let CellIdentifier = "CellIdentifier"
override func viewDidLoad() {
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier:CellIdentifier)
}
// UI TableView.
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier(CellIdentifier) as UITableViewCell
cell.textLabel?.text = data[indexPath.row]
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment