Skip to content

Instantly share code, notes, and snippets.

@konrad1977
Created March 19, 2015 10:01
Show Gist options
  • Save konrad1977/acce39f0d05180851f95 to your computer and use it in GitHub Desktop.
Save konrad1977/acce39f0d05180851f95 to your computer and use it in GitHub Desktop.
Functional working tableViewController
class TableViewContorllerThatWorks: UITableViewController {
override init(style: UITableViewStyle) {
super.init(style: style)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var data: [String] = []
var configureCell: (UITableViewCell, String) -> () = { _ in () }
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: nil)
configureCell(cell, data[indexPath.row])
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.data.count
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment