Last active
March 30, 2016 05:29
-
-
Save groue/dd57094363b14e05357b316e7220bcb3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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