mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-25 02:41:10 +01:00
WIP
This commit is contained in:
@@ -99,7 +99,6 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public override func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
@@ -113,7 +112,6 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
|
||||
@@ -67,7 +67,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
@@ -81,7 +80,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
@@ -127,7 +125,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObject`s that were inserted to the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func insertedObjects() -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.insertedObjects()
|
||||
@@ -140,7 +137,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObject`s of the specified type that were inserted to the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func insertedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.insertedObjects(entity)
|
||||
@@ -152,7 +148,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObjectID`s that were inserted to the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func insertedObjectIDs() -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.insertedObjectIDs()
|
||||
@@ -165,7 +160,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObjectID`s of the specified type that were inserted to the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func insertedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.insertedObjectIDs(entity)
|
||||
@@ -177,7 +171,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObject`s that were updated to the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func updatedObjects() -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.updatedObjects()
|
||||
@@ -190,7 +183,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObject`s of the specified type that were updated in the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func updatedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.updatedObjects(entity)
|
||||
@@ -202,7 +194,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObjectID`s that were updated in the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func updatedObjectIDs() -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.updatedObjectIDs()
|
||||
@@ -215,7 +206,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObjectID`s of the specified type that were updated in the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func updatedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.updatedObjectIDs(entity)
|
||||
@@ -227,7 +217,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObject`s that were deleted from the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func deletedObjects() -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.deletedObjects()
|
||||
@@ -240,7 +229,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObject`s of the specified type that were deleted from the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func deletedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.deletedObjects(entity)
|
||||
@@ -253,7 +241,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: an `NSSet` of pending `NSManagedObjectID`s of the specified type that were deleted from the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func deletedObjectIDs() -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.deletedObjectIDs()
|
||||
@@ -266,7 +253,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `Set` of pending `NSManagedObjectID`s of the specified type that were deleted from the transaction.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func deletedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.deletedObjectIDs(entity)
|
||||
|
||||
@@ -80,6 +80,7 @@ public extension CSCoreStore {
|
||||
- returns: the `CSInMemoryStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
@discardableResult
|
||||
public static func addInMemoryStorageAndWaitAndReturnError(_ error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
|
||||
return self.defaultStack.addInMemoryStorageAndWaitAndReturnError(error)
|
||||
@@ -95,6 +96,7 @@ public extension CSCoreStore {
|
||||
- returns: the `CSSQLiteStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
@discardableResult
|
||||
public static func addSQLiteStorageAndWaitAndReturnError(_ error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
|
||||
return self.defaultStack.addSQLiteStorageAndWaitAndReturnError(error)
|
||||
@@ -114,6 +116,7 @@ public extension CSCoreStore {
|
||||
- returns: the `CSInMemoryStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
@discardableResult
|
||||
public static func addInMemoryStorageAndWait(_ storage: CSInMemoryStore, error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
|
||||
return self.defaultStack.addInMemoryStorageAndWait(storage, error: error)
|
||||
@@ -133,6 +136,7 @@ public extension CSCoreStore {
|
||||
- returns: the `CSSQLiteStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
@discardableResult
|
||||
public static func addSQLiteStorageAndWait(_ storage: CSSQLiteStore, error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
|
||||
return self.defaultStack.addSQLiteStorageAndWait(storage, error: error)
|
||||
|
||||
@@ -74,9 +74,9 @@ public extension CSDataStack {
|
||||
dataStack: self.bridgeToSwift,
|
||||
from: from.bridgeToSwift,
|
||||
sectionBy: nil,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
applyFetchClauses: { (fetchRequest) in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(unsafeBitCast(fetchRequest, to: NSFetchRequest<NSFetchRequestResult>.self)) }
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -104,9 +104,9 @@ public extension CSDataStack {
|
||||
dataStack: self.bridgeToSwift,
|
||||
from: from.bridgeToSwift,
|
||||
sectionBy: nil,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
applyFetchClauses: { (fetchRequest) in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(unsafeBitCast(fetchRequest, to: NSFetchRequest<NSFetchRequestResult>.self)) }
|
||||
},
|
||||
createAsynchronously: {
|
||||
|
||||
@@ -141,9 +141,9 @@ public extension CSDataStack {
|
||||
dataStack: self.bridgeToSwift,
|
||||
from: from.bridgeToSwift,
|
||||
sectionBy: sectionBy.bridgeToSwift,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
applyFetchClauses: { (fetchRequest) in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(unsafeBitCast(fetchRequest, to: NSFetchRequest<NSFetchRequestResult>.self)) }
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -171,9 +171,9 @@ public extension CSDataStack {
|
||||
dataStack: self.bridgeToSwift,
|
||||
from: from.bridgeToSwift,
|
||||
sectionBy: sectionBy.bridgeToSwift,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
applyFetchClauses: { (fetchRequest) in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(unsafeBitCast(fetchRequest, to: NSFetchRequest<NSFetchRequestResult>.self)) }
|
||||
},
|
||||
createAsynchronously: {
|
||||
|
||||
|
||||
@@ -166,6 +166,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `CSInMemoryStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
@discardableResult
|
||||
public func addInMemoryStorageAndWaitAndReturnError(_ error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
|
||||
return bridge(error) {
|
||||
@@ -184,6 +185,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `CSSQLiteStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
@discardableResult
|
||||
public func addSQLiteStorageAndWaitAndReturnError(_ error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
|
||||
return bridge(error) {
|
||||
@@ -206,6 +208,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `CSInMemoryStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
@discardableResult
|
||||
public func addInMemoryStorageAndWait(_ storage: CSInMemoryStore, error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
|
||||
return bridge(error) {
|
||||
@@ -228,6 +231,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `CSSQLiteStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
@discardableResult
|
||||
public func addSQLiteStorageAndWait(_ storage: CSSQLiteStore, error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
@@ -95,7 +95,7 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
case .unknownError:
|
||||
return .unknown
|
||||
|
||||
case .differentPersistentStoreExistsAtURL:
|
||||
case .differentStorageExistsAtURL:
|
||||
guard case let existingPersistentStoreURL as URL = info["existingPersistentStoreURL"] else {
|
||||
|
||||
return .unknown
|
||||
@@ -148,7 +148,7 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
info = [:]
|
||||
|
||||
case .differentStorageExistsAtURL(let existingPersistentStoreURL):
|
||||
code = .differentPersistentStoreExistsAtURL
|
||||
code = .differentStorageExistsAtURL
|
||||
info = [
|
||||
"existingPersistentStoreURL": existingPersistentStoreURL
|
||||
]
|
||||
@@ -208,7 +208,7 @@ public enum CSErrorCode: Int {
|
||||
/**
|
||||
The `NSPersistentStore` could note be initialized because another store existed at the specified `NSURL`.
|
||||
*/
|
||||
case differentPersistentStoreExistsAtURL
|
||||
case differentStorageExistsAtURL
|
||||
|
||||
/**
|
||||
An `NSMappingModel` could not be found for a specific source and destination model versions.
|
||||
|
||||
@@ -515,9 +515,9 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public func refetch(_ fetchClauses: [CSFetchClause]) {
|
||||
|
||||
self.bridgeToSwift.refetch { (fetchRequest: NSFetchRequest<NSManagedObject>) in
|
||||
self.bridgeToSwift.refetch { (fetchRequest) in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(unsafeBitCast(fetchRequest, to: NSFetchRequest<NSFetchRequestResult>.self)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public override func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
@@ -113,7 +112,6 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: an editable proxy for the specified `NSManagedObject`.
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
|
||||
@@ -79,17 +79,17 @@ public extension CoreStoreSwiftType where ObjectiveCType: CoreStoreObjectiveCTyp
|
||||
|
||||
// MARK: - Internal
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType>(@noescape _ closure: () -> T) -> T.ObjectiveCType {
|
||||
internal func bridge<T: CoreStoreSwiftType where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType>(_ closure: @noescape () -> T) -> T.ObjectiveCType {
|
||||
|
||||
return closure().bridgeToObjectiveC
|
||||
}
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType>(@noescape _ closure: () -> T?) -> T.ObjectiveCType? {
|
||||
internal func bridge<T: CoreStoreSwiftType where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType>(_ closure: @noescape () -> T?) -> T.ObjectiveCType? {
|
||||
|
||||
return closure()?.bridgeToObjectiveC
|
||||
}
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType>(@noescape _ closure: () throws -> T) throws -> T.ObjectiveCType {
|
||||
internal func bridge<T: CoreStoreSwiftType where T.ObjectiveCType: CoreStoreObjectiveCType, T == T.ObjectiveCType.SwiftType>(_ closure: @noescape () throws -> T) throws -> T.ObjectiveCType {
|
||||
|
||||
do {
|
||||
|
||||
@@ -101,7 +101,7 @@ internal func bridge<T: CoreStoreSwiftType where T.ObjectiveCType: CoreStoreObje
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge(@noescape _ closure: () throws -> Void) throws {
|
||||
internal func bridge(_ closure: @noescape () throws -> Void) throws {
|
||||
|
||||
do {
|
||||
|
||||
@@ -113,7 +113,7 @@ internal func bridge(@noescape _ closure: () throws -> Void) throws {
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ error: NSErrorPointer, @noescape _ closure: () throws -> T) -> T.ObjectiveCType? {
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ error: NSErrorPointer, _ closure: @noescape () throws -> T) -> T.ObjectiveCType? {
|
||||
|
||||
do {
|
||||
|
||||
@@ -128,7 +128,7 @@ internal func bridge<T: CoreStoreSwiftType>(_ error: NSErrorPointer, @noescape _
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge(_ error: NSErrorPointer, @noescape _ closure: () throws -> Void) -> Bool {
|
||||
internal func bridge(_ error: NSErrorPointer, _ closure: @noescape () throws -> Void) -> Bool {
|
||||
|
||||
do {
|
||||
|
||||
@@ -143,7 +143,7 @@ internal func bridge(_ error: NSErrorPointer, @noescape _ closure: () throws ->
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge<T>(_ error: NSErrorPointer, @noescape _ closure: () throws -> T?) -> T? {
|
||||
internal func bridge<T>(_ error: NSErrorPointer, _ closure: @noescape () throws -> T?) -> T? {
|
||||
|
||||
do {
|
||||
|
||||
@@ -158,7 +158,7 @@ internal func bridge<T>(_ error: NSErrorPointer, @noescape _ closure: () throws
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ error: NSErrorPointer, @noescape _ closure: () throws -> [T]) -> [T.ObjectiveCType]? {
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ error: NSErrorPointer, _ closure: @noescape () throws -> [T]) -> [T.ObjectiveCType]? {
|
||||
|
||||
do {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user