allow accessing a ListMonitor as a flat array when using API's without section info

This commit is contained in:
John Estropia
2016-06-20 19:18:31 +09:00
parent d25f751089
commit e50dd9881d

View File

@@ -82,7 +82,7 @@ public final class ListMonitor<T: NSManagedObject> {
*/
public subscript(index: Int) -> T {
return self[0, index]
return self.objectsInAllSections()[index]
}
/**
@@ -93,7 +93,12 @@ public final class ListMonitor<T: NSManagedObject> {
*/
public subscript(safeIndex index: Int) -> T? {
return self[safeSectionIndex: 0, safeItemIndex: index]
let objects = self.objectsInAllSections()
guard objects.indices.contains(index) else {
return nil
}
return objects[index]
}
/**