ManagedObjectListController demo

This commit is contained in:
John Rommel Estropia
2015-05-06 01:06:22 +09:00
parent d043d64cb1
commit 8d42a4a885
24 changed files with 1566 additions and 453 deletions

View File

@@ -34,15 +34,25 @@ public extension DataStack {
// MARK: Public
public func observeObjectList<T: NSManagedObject>(from: From<T>, _ queryClauses: FetchClause...) -> ManagedObjectListController<T> {
public func observeObject<T: NSManagedObject>(object: T) -> ManagedObjectController<T> {
HardcoreData.assert(GCDQueue.Main.isCurrentExecutionContext(), "Attempted to fetch from a \(typeName(self)) outside the main queue.")
HardcoreData.assert(GCDQueue.Main.isCurrentExecutionContext(), "Attempted to observe objects from \(typeName(self)) outside the main queue.")
return ManagedObjectController(
dataStack: self,
object: object
)
}
public func observeObjectList<T: NSManagedObject>(from: From<T>, _ groupBy: GroupBy? = nil, _ queryClauses: FetchClause...) -> ManagedObjectListController<T> {
HardcoreData.assert(GCDQueue.Main.isCurrentExecutionContext(), "Attempted to observe objects from \(typeName(self)) outside the main queue.")
// TODO: sectionNameKeyPath and cacheResults
return ManagedObjectListController(
dataStack: self,
entity: T.self,
sectionNameKeyPath: nil,
sectionNameKeyPath: groupBy?.keyPaths.first,
cacheResults: false,
queryClauses: queryClauses
)