Created
March 19, 2015 10:01
-
-
Save konrad1977/acce39f0d05180851f95 to your computer and use it in GitHub Desktop.
Functional working tableViewController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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