Skip to content

Instantly share code, notes, and snippets.

@groue
Last active March 30, 2016 05:29
Show Gist options
  • Save groue/dd57094363b14e05357b316e7220bcb3 to your computer and use it in GitHub Desktop.
Save groue/dd57094363b14e05357b316e7220bcb3 to your computer and use it in GitHub Desktop.
// MARK: - UITableViewDataSource
extension FetchedRecordsControllerDemoViewController {
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return personsController.sections.count
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return personsController.sections[section].numberOfRecords
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Person", forIndexPath: indexPath)
configureCell(cell, atIndexPath: indexPath)
return cell
}
// Configure a cell
func configureCell(cell: UITableViewCell, atIndexPath indexPath: NSIndexPath) {
let person = personsController.recordAtIndexPath(indexPath)
cell.textLabel?.text = person.name
cell.detailTextLabel?.text = abs(person.score) > 1 ? "\(person.score) points" : "0 point"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment