mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-17 23:13:52 +01:00
FetchableSource and QueryableSource protocols
This commit is contained in:
@@ -40,14 +40,7 @@ public extension CSBaseDataTransaction {
|
||||
@objc
|
||||
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
||||
|
||||
do {
|
||||
|
||||
return try self.bridgeToSwift.context.existingObject(with: object.objectID)
|
||||
}
|
||||
catch _ {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.bridgeToSwift.context.fetchExisting(object)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,14 +52,7 @@ public extension CSBaseDataTransaction {
|
||||
@objc
|
||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
||||
|
||||
do {
|
||||
|
||||
return try self.bridgeToSwift.context.existingObject(with: objectID)
|
||||
}
|
||||
catch _ {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.bridgeToSwift.context.fetchExisting(objectID)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +64,7 @@ public extension CSBaseDataTransaction {
|
||||
@objc
|
||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
||||
|
||||
return objects.flatMap { try? self.bridgeToSwift.context.existingObject(with: $0.objectID) }
|
||||
return self.bridgeToSwift.context.fetchExisting(objects)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +76,7 @@ public extension CSBaseDataTransaction {
|
||||
@objc
|
||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
||||
|
||||
return objectIDs.flatMap { try? self.bridgeToSwift.context.existingObject(with: $0) }
|
||||
return self.bridgeToSwift.context.fetchExisting(objectIDs)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,14 +40,7 @@ public extension CSDataStack {
|
||||
@objc
|
||||
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
|
||||
|
||||
do {
|
||||
|
||||
return try self.bridgeToSwift.mainContext.existingObject(with: object.objectID)
|
||||
}
|
||||
catch _ {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.bridgeToSwift.mainContext.fetchExisting(object)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,14 +52,7 @@ public extension CSDataStack {
|
||||
@objc
|
||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
|
||||
|
||||
do {
|
||||
|
||||
return try self.bridgeToSwift.mainContext.existingObject(with: objectID)
|
||||
}
|
||||
catch _ {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.bridgeToSwift.mainContext.fetchExisting(objectID)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +64,7 @@ public extension CSDataStack {
|
||||
@objc
|
||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
|
||||
|
||||
return objects.flatMap { try? self.bridgeToSwift.mainContext.existingObject(with: $0.objectID) }
|
||||
return self.bridgeToSwift.mainContext.fetchExisting(objects)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +76,7 @@ public extension CSDataStack {
|
||||
@objc
|
||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
|
||||
|
||||
return objectIDs.flatMap { try? self.bridgeToSwift.mainContext.existingObject(with: $0) }
|
||||
return self.bridgeToSwift.mainContext.fetchExisting(objectIDs)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ public extension CSDataStack {
|
||||
|
||||
/**
|
||||
Utility for creating an `NSFetchedResultsController` from the `CSDataStack`. This is useful when an `NSFetchedResultsController` is preferred over the overhead of `CSListMonitor`s abstraction.
|
||||
- Note: It is the caller's responsibility to call `-performFetch:` on the created `NSFetchedResultsController`.
|
||||
|
||||
- parameter from: a `CSFrom` clause indicating the entity type
|
||||
- parameter sectionBy: a `CSSectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
@@ -60,6 +61,7 @@ public extension CSUnsafeDataTransaction {
|
||||
|
||||
/**
|
||||
Utility for creating an `NSFetchedResultsController` from the `CSUnsafeDataTransaction`. This is useful when an `NSFetchedResultsController` is preferred over the overhead of `CSListMonitor`s abstraction.
|
||||
- Note: It is the caller's responsibility to call `-performFetch:` on the created `NSFetchedResultsController`.
|
||||
|
||||
- parameter from: a `CSFrom` clause indicating the entity type
|
||||
- parameter sectionBy: a `CSSectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections
|
||||
|
||||
Reference in New Issue
Block a user