mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Improve FetchedRecordsController misuse feedback
This commit is contained in:
1 parent
ee9c959262
commit
ad4d2831c9
1 file changed
+11
-5
@@ -794,7 +794,9 @@ private func databaseEventFilter(readInfo: SelectStatement.ReadInfo) -> (Databas
|
||||
/// You typically use the sections array when implementing
|
||||
/// UITableViewDataSource methods, such as `numberOfSectionsInTableView`.
|
||||
public var sections: [FetchedRecordsSectionInfo<Record>] {
|
||||
// We only support a single section
|
||||
// We only support a single section so far.
|
||||
// We also return a single section when there are no fetched
|
||||
// records, just like NSFetchedResultsController.
|
||||
return [FetchedRecordsSectionInfo(controller: self)]
|
||||
}
|
||||
}
|
||||
@@ -1055,14 +1057,18 @@ private func databaseEventFilter(readInfo: SelectStatement.ReadInfo) -> (Databas
|
||||
|
||||
/// The number of records (rows) in the section.
|
||||
public var numberOfRecords: Int {
|
||||
// We only support a single section
|
||||
return controller.fetchedItems!.count
|
||||
guard let items = controller.fetchedItems else {
|
||||
fatalError("the performFetch() method must be called before accessing section contents")
|
||||
}
|
||||
return items.count
|
||||
}
|
||||
|
||||
/// The array of records in the section.
|
||||
public var records: [Record] {
|
||||
// We only support a single section
|
||||
return controller.fetchedItems!.map { $0.record }
|
||||
guard let items = controller.fetchedItems else {
|
||||
fatalError("the performFetch() method must be called before accessing section contents")
|
||||
}
|
||||
return items.map { $0.record }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user