FetchedRecordsController.recordAtIndexPath returns a non-optional (as NSFetchedResultsController does)

This commit is contained in:
Gwendal Roué committed 2016-03-23 09:08:38 +01:00
1 parent d0c5e98366
commit c4c0e67407
2 files changed
+4 -7

No files matched your search

@@ -143,13 +143,13 @@ class MasterViewController: UITableViewController {
}
private func configureCell(cell: UITableViewCell, atIndexPath indexPath:NSIndexPath) {
let person = fetchedRecordsController.recordAtIndexPath(indexPath)!
let person = fetchedRecordsController.recordAtIndexPath(indexPath)
cell.textLabel!.text = "\(person.position) - \(person.fullName)"
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
// Delete the person
let person = fetchedRecordsController.recordAtIndexPath(indexPath)!
let person = fetchedRecordsController.recordAtIndexPath(indexPath)
try! person.delete(dbQueue)
}
}
+2 -5
View File
@@ -111,12 +111,9 @@ public class FetchedRecordsController<T: RowConvertible> {
/// Returns the fetched record at a given indexPath.
public func recordAtIndexPath(indexPath: NSIndexPath) -> T? {
public func recordAtIndexPath(indexPath: NSIndexPath) -> T {
precondition(NSThread.isMainThread(), "Must be called on the main thread")
if let item = self.mainItems?[indexPath.indexAtPosition(1)] {
return item.record
}
return nil
return self.mainItems![indexPath.indexAtPosition(1)].record
}
/// Returns the indexPath of a given record.