mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-30 12:44:20 +02:00
WIP: segfault
This commit is contained in:
@@ -43,7 +43,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- parameter completion: the block executed after the save completes. Success or failure is reported by the `CSSaveResult` argument of the block.
|
||||
*/
|
||||
@objc
|
||||
public func commitWithCompletion(completion: ((result: CSSaveResult) -> Void)?) {
|
||||
public func commitWithCompletion(_ completion: ((result: CSSaveResult) -> Void)?) {
|
||||
|
||||
self.bridgeToSwift.commit { (result) in
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: a `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
@objc
|
||||
public func beginSynchronous(closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? {
|
||||
public func beginSynchronous(_ closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? {
|
||||
|
||||
return bridge {
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: a new `NSManagedObject` instance of the specified entity type.
|
||||
*/
|
||||
@objc
|
||||
public override func createInto(into: CSInto) -> AnyObject {
|
||||
public override func createInto(_ into: CSInto) -> AnyObject {
|
||||
|
||||
return self.bridgeToSwift.create(into.bridgeToSwift)
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public override func editObject(object: NSManagedObject?) -> AnyObject? {
|
||||
public override func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public override func editInto(into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- parameter object: the `NSManagedObject` type to be deleted
|
||||
*/
|
||||
@objc
|
||||
public override func deleteObject(object: NSManagedObject?) {
|
||||
public override func deleteObject(_ object: NSManagedObject?) {
|
||||
|
||||
self.bridgeToSwift.delete(object)
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- parameter objects: the `NSManagedObject`s type to be deleted
|
||||
*/
|
||||
@objc
|
||||
public override func deleteObjects(objects: [NSManagedObject]) {
|
||||
public override func deleteObjects(_ objects: [NSManagedObject]) {
|
||||
|
||||
self.bridgeToSwift.delete(objects)
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchExistingObject(object: NSManagedObject) -> AnyObject? {
|
||||
public func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
|
||||
|
||||
do {
|
||||
|
||||
return try self.bridgeToSwift.context.existingObjectWithID(object.objectID)
|
||||
return try self.bridgeToSwift.context.existingObject(with: object.objectID)
|
||||
}
|
||||
catch _ {
|
||||
|
||||
@@ -59,11 +59,11 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchExistingObjectWithID(objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
do {
|
||||
|
||||
return try self.bridgeToSwift.context.existingObjectWithID(objectID)
|
||||
return try self.bridgeToSwift.context.existingObject(with: objectID)
|
||||
}
|
||||
catch _ {
|
||||
|
||||
@@ -79,9 +79,9 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchExistingObjects(objects: [NSManagedObject]) -> [AnyObject] {
|
||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
|
||||
|
||||
return objects.flatMap { try? self.bridgeToSwift.context.existingObjectWithID($0.objectID) }
|
||||
return objects.flatMap { try? self.bridgeToSwift.context.existingObject(with: $0.objectID) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,9 +92,9 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchExistingObjectsWithIDs(objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
|
||||
return objectIDs.flatMap { try? self.bridgeToSwift.context.existingObjectWithID($0) }
|
||||
return objectIDs.flatMap { try? self.bridgeToSwift.context.existingObject(with: $0) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchOneFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
@@ -124,7 +124,7 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchAllFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
@@ -142,7 +142,7 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchCountFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> NSNumber? {
|
||||
public func fetchCountFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> NSNumber? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
@@ -160,7 +160,7 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchObjectIDFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
||||
public func fetchObjectIDFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
@@ -181,7 +181,7 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func queryValueFrom(from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
@@ -202,7 +202,7 @@ public extension CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func queryAttributesFrom(from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
|
||||
CoreStore.assert(
|
||||
self.bridgeToSwift.isRunningInAllowedQueue(),
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a new `NSManagedObject` instance of the specified entity type.
|
||||
*/
|
||||
@objc
|
||||
public func createInto(into: CSInto) -> AnyObject {
|
||||
public func createInto(_ into: CSInto) -> AnyObject {
|
||||
|
||||
return self.bridgeToSwift.create(into.bridgeToSwift)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func editObject(object: NSManagedObject?) -> AnyObject? {
|
||||
public func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func editInto(into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter object: the `NSManagedObject` to be deleted
|
||||
*/
|
||||
@objc
|
||||
public func deleteObject(object: NSManagedObject?) {
|
||||
public func deleteObject(_ object: NSManagedObject?) {
|
||||
|
||||
self.bridgeToSwift.delete(object)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter objects: the `NSManagedObject`s to be deleted
|
||||
*/
|
||||
@objc
|
||||
public func deleteObjects(objects: [NSManagedObject]) {
|
||||
public func deleteObjects(_ objects: [NSManagedObject]) {
|
||||
|
||||
self.bridgeToSwift.delete(objects)
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func insertedObjectsOfType(entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
public func insertedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.insertedObjects(entity)
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func insertedObjectIDsOfType(entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
public func insertedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.insertedObjectIDs(entity)
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func updatedObjectsOfType(entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
public func updatedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.updatedObjects(entity)
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func updatedObjectIDsOfType(entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
public func updatedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.updatedObjectIDs(entity)
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func deletedObjectsOfType(entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
public func deletedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject> {
|
||||
|
||||
return self.bridgeToSwift.deletedObjects(entity)
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func deletedObjectIDsOfType(entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
public func deletedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID> {
|
||||
|
||||
return self.bridgeToSwift.deletedObjectIDs(entity)
|
||||
}
|
||||
@@ -280,7 +280,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
return ObjectIdentifier(self.bridgeToSwift).hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSBaseDataTransaction else {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import CoreData
|
||||
public protocol CSFetchClause {
|
||||
|
||||
@objc
|
||||
func applyToFetchRequest(fetchRequest: NSFetchRequest)
|
||||
func applyToFetchRequest(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>)
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public protocol CSFetchClause {
|
||||
public protocol CSQueryClause {
|
||||
|
||||
@objc
|
||||
func applyToFetchRequest(fetchRequest: NSFetchRequest)
|
||||
func applyToFetchRequest(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>)
|
||||
}
|
||||
|
||||
|
||||
@@ -68,5 +68,5 @@ public protocol CSQueryClause {
|
||||
public protocol CSDeleteClause {
|
||||
|
||||
@objc
|
||||
func applyToFetchRequest(fetchRequest: NSFetchRequest)
|
||||
func applyToFetchRequest(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public extension CSCoreStore {
|
||||
- parameter storage: the `CSInMemoryStore` instance
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
|
||||
*/
|
||||
public static func addInMemoryStorage(storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
|
||||
public static func addInMemoryStorage(_ storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
|
||||
|
||||
self.defaultStack.addInMemoryStorage(storage, completion: completion)
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public extension CSCoreStore {
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
public static func addSQLiteStorage(storage: CSSQLiteStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> NSProgress? {
|
||||
public static func addSQLiteStorage(_ storage: CSSQLiteStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
|
||||
return self.defaultStack.addSQLiteStorage(storage, completion: completion, error: error)
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public extension CSCoreStore {
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
public static func upgradeStorageIfNeeded(storage: CSSQLiteStore, completion: (CSMigrationResult) -> Void, error: NSErrorPointer) -> NSProgress? {
|
||||
public static func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
|
||||
return self.defaultStack.upgradeStorageIfNeeded(storage, completion: completion, error: error)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func requiredMigrationsForSQLiteStore(storage: CSSQLiteStore, error: NSErrorPointer) -> [CSMigrationType]? {
|
||||
public static func requiredMigrationsForSQLiteStore(_ storage: CSSQLiteStore, error: NSErrorPointer) -> [CSMigrationType]? {
|
||||
|
||||
return self.defaultStack.requiredMigrationsForSQLiteStore(storage, error: error)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func monitorObject(object: NSManagedObject) -> CSObjectMonitor {
|
||||
public static func monitorObject(_ object: NSManagedObject) -> CSObjectMonitor {
|
||||
|
||||
return self.defaultStack.monitorObject(object)
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func monitorListFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> CSListMonitor {
|
||||
public static func monitorListFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> CSListMonitor {
|
||||
|
||||
return self.defaultStack.monitorListFrom(from, fetchClauses: fetchClauses)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public extension CSCoreStore {
|
||||
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
@objc
|
||||
public static func monitorListByCreatingAsynchronously(createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
|
||||
public static func monitorListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
|
||||
|
||||
return self.defaultStack.monitorListByCreatingAsynchronously(
|
||||
createAsynchronously,
|
||||
@@ -87,7 +87,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func monitorSectionedListFrom(from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) -> CSListMonitor {
|
||||
public static func monitorSectionedListFrom(_ from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) -> CSListMonitor {
|
||||
|
||||
return self.defaultStack.monitorSectionedListFrom(
|
||||
from,
|
||||
@@ -105,7 +105,7 @@ public extension CSCoreStore {
|
||||
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
@objc
|
||||
public static func monitorSectionedListByCreatingAsynchronously(createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
|
||||
public static func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
|
||||
|
||||
self.defaultStack.monitorSectionedListByCreatingAsynchronously(
|
||||
createAsynchronously,
|
||||
|
||||
@@ -39,7 +39,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchExistingObject(object: NSManagedObject) -> AnyObject? {
|
||||
public static func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
|
||||
|
||||
return self.defaultStack.fetchExistingObject(object)
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchExistingObjectWithID(objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public static func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
return self.defaultStack.fetchExistingObjectWithID(objectID)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchExistingObjects(objects: [NSManagedObject]) -> [AnyObject] {
|
||||
public static func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
|
||||
|
||||
return self.defaultStack.fetchExistingObjects(objects)
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchExistingObjectsWithIDs(objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
public static func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
|
||||
return self.defaultStack.fetchExistingObjectsWithIDs(objectIDs)
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchOneFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
public static func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
|
||||
return self.defaultStack.fetchOneFrom(from, fetchClauses: fetchClauses)
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchAllFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
public static func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
|
||||
return self.defaultStack.fetchAllFrom(from, fetchClauses: fetchClauses)
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchCountFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> NSNumber? {
|
||||
public static func fetchCountFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> NSNumber? {
|
||||
|
||||
return self.defaultStack.fetchCountFrom(from, fetchClauses: fetchClauses)
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchObjectIDFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
||||
public static func fetchObjectIDFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
||||
|
||||
return self.defaultStack.fetchObjectIDFrom(from, fetchClauses: fetchClauses)
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func fetchObjectIDsFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> [NSManagedObjectID]? {
|
||||
public static func fetchObjectIDsFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [NSManagedObjectID]? {
|
||||
|
||||
return self.defaultStack.fetchObjectIDsFrom(from, fetchClauses: fetchClauses)
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func queryValueFrom(from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
public static func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
|
||||
return self.defaultStack.queryValueFrom(from, selectClause: selectClause, queryClauses: queryClauses)
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func queryAttributesFrom(from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public static func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
|
||||
return self.defaultStack.queryAttributesFrom(from, selectClause: selectClause, queryClauses: queryClauses)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public extension CSCoreStore {
|
||||
- returns: the `NSManagedObject` class for the given entity name, or `nil` if not found
|
||||
*/
|
||||
@objc
|
||||
public static func entityClassWithName(name: String) -> NSManagedObject.Type? {
|
||||
public static func entityClassWithName(_ name: String) -> NSManagedObject.Type? {
|
||||
|
||||
return CoreStore.entityTypesByName[name]
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public extension CSCoreStore {
|
||||
Returns the `NSEntityDescription` for the specified `NSManagedObject` subclass from `defaultStack`'s model.
|
||||
*/
|
||||
@objc
|
||||
public static func entityDescriptionForClass(type: NSManagedObject.Type) -> NSEntityDescription? {
|
||||
public static func entityDescriptionForClass(_ type: NSManagedObject.Type) -> NSEntityDescription? {
|
||||
|
||||
return CoreStore.entityDescriptionForType(type)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public extension CSCoreStore {
|
||||
- returns: the `CSInMemoryStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
public static func addInMemoryStorageAndWaitAndReturnError(error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
public static func addInMemoryStorageAndWaitAndReturnError(_ error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
|
||||
return self.defaultStack.addInMemoryStorageAndWaitAndReturnError(error)
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public extension CSCoreStore {
|
||||
- returns: the `CSSQLiteStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
public static func addSQLiteStorageAndWaitAndReturnError(error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
public static func addSQLiteStorageAndWaitAndReturnError(_ error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
|
||||
return self.defaultStack.addSQLiteStorageAndWaitAndReturnError(error)
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public extension CSCoreStore {
|
||||
- returns: the `CSInMemoryStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
public static func addInMemoryStorageAndWait(storage: CSInMemoryStore, error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
public static func addInMemoryStorageAndWait(_ storage: CSInMemoryStore, error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
|
||||
return self.defaultStack.addInMemoryStorageAndWait(storage, error: error)
|
||||
}
|
||||
@@ -133,8 +133,8 @@ public extension CSCoreStore {
|
||||
- returns: the `CSSQLiteStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
public static func addSQLiteStorageAndWait(storage: CSSQLiteStore, error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
public static func addSQLiteStorageAndWait(_ storage: CSSQLiteStore, error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
|
||||
return self.defaultStack.addSQLiteStorageAndWait(storage, error: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public extension CSCoreStore {
|
||||
- parameter closure: the block where creates, updates, and deletes can be made to the transaction. Transaction blocks are executed serially in a background queue, and all changes are made from a concurrent `NSManagedObjectContext`.
|
||||
*/
|
||||
@objc
|
||||
public static func beginAsynchronous(closure: (transaction: CSAsynchronousDataTransaction) -> Void) {
|
||||
public static func beginAsynchronous(_ closure: (transaction: CSAsynchronousDataTransaction) -> Void) {
|
||||
|
||||
return CoreStore.beginAsynchronous { (transaction) in
|
||||
|
||||
@@ -51,7 +51,7 @@ public extension CSCoreStore {
|
||||
- returns: a `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
@objc
|
||||
public static func beginSynchronous(closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? {
|
||||
public static func beginSynchronous(_ closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? {
|
||||
|
||||
return bridge {
|
||||
|
||||
@@ -86,7 +86,7 @@ public extension CSCoreStore {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public static func beginUnsafeWithSupportsUndo(supportsUndo: Bool) -> CSUnsafeDataTransaction {
|
||||
public static func beginUnsafeWithSupportsUndo(_ supportsUndo: Bool) -> CSUnsafeDataTransaction {
|
||||
|
||||
return bridge {
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public extension CSDataStack {
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
|
||||
*/
|
||||
@objc
|
||||
public func addInMemoryStorage(storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
|
||||
public func addInMemoryStorage(_ storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
|
||||
|
||||
self.bridgeToSwift.addStorage(
|
||||
storage.bridgeToSwift,
|
||||
@@ -79,7 +79,7 @@ public extension CSDataStack {
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
public func addSQLiteStorage(storage: CSSQLiteStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> NSProgress? {
|
||||
public func addSQLiteStorage(_ storage: CSSQLiteStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
@@ -99,7 +99,7 @@ public extension CSDataStack {
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
public func upgradeStorageIfNeeded(storage: CSSQLiteStore, completion: (CSMigrationResult) -> Void, error: NSErrorPointer) -> NSProgress? {
|
||||
public func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
@@ -119,11 +119,11 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func requiredMigrationsForSQLiteStore(storage: CSSQLiteStore, error: NSErrorPointer) -> [CSMigrationType]? {
|
||||
public func requiredMigrationsForSQLiteStore(_ storage: CSSQLiteStore, error: NSErrorPointer) -> [CSMigrationType]? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
try self.bridgeToSwift.requiredMigrationsForStorage(storage.bridgeToSwift)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func monitorObject(object: NSManagedObject) -> CSObjectMonitor {
|
||||
public func monitorObject(_ object: NSManagedObject) -> CSObjectMonitor {
|
||||
|
||||
return bridge {
|
||||
|
||||
@@ -58,10 +58,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func monitorListFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> CSListMonitor {
|
||||
public func monitorListFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> CSListMonitor {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -76,7 +76,7 @@ public extension CSDataStack {
|
||||
sectionBy: nil,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -90,10 +90,10 @@ public extension CSDataStack {
|
||||
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
@objc
|
||||
public func monitorListByCreatingAsynchronously(createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
|
||||
public func monitorListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -106,7 +106,7 @@ public extension CSDataStack {
|
||||
sectionBy: nil,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
},
|
||||
createAsynchronously: {
|
||||
|
||||
@@ -125,10 +125,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func monitorSectionedListFrom(from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) -> CSListMonitor {
|
||||
public func monitorSectionedListFrom(_ from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) -> CSListMonitor {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -143,7 +143,7 @@ public extension CSDataStack {
|
||||
sectionBy: sectionBy.bridgeToSwift,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -157,10 +157,10 @@ public extension CSDataStack {
|
||||
- parameter sectionBy: a `CSSectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
public func monitorSectionedListByCreatingAsynchronously(createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
|
||||
public func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
CoreStore.assert(
|
||||
@@ -173,7 +173,7 @@ public extension CSDataStack {
|
||||
sectionBy: sectionBy.bridgeToSwift,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
},
|
||||
createAsynchronously: {
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchExistingObject(object: NSManagedObject) -> AnyObject? {
|
||||
public func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
|
||||
|
||||
do {
|
||||
|
||||
return try self.bridgeToSwift.mainContext.existingObjectWithID(object.objectID)
|
||||
return try self.bridgeToSwift.mainContext.existingObject(with: object.objectID)
|
||||
}
|
||||
catch _ {
|
||||
|
||||
@@ -59,11 +59,11 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchExistingObjectWithID(objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
do {
|
||||
|
||||
return try self.bridgeToSwift.mainContext.existingObjectWithID(objectID)
|
||||
return try self.bridgeToSwift.mainContext.existingObject(with: objectID)
|
||||
}
|
||||
catch _ {
|
||||
|
||||
@@ -79,9 +79,9 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchExistingObjects(objects: [NSManagedObject]) -> [AnyObject] {
|
||||
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
|
||||
|
||||
return objects.flatMap { try? self.bridgeToSwift.mainContext.existingObjectWithID($0.objectID) }
|
||||
return objects.flatMap { try? self.bridgeToSwift.mainContext.existingObject(with: $0.objectID) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,9 +92,9 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchExistingObjectsWithIDs(objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
|
||||
|
||||
return objectIDs.flatMap { try? self.bridgeToSwift.mainContext.existingObjectWithID($0) }
|
||||
return objectIDs.flatMap { try? self.bridgeToSwift.mainContext.existingObject(with: $0) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,10 +106,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchOneFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
return self.bridgeToSwift.mainContext.fetchOne(from, fetchClauses)
|
||||
@@ -124,10 +124,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchAllFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
return self.bridgeToSwift.mainContext.fetchAll(from, fetchClauses)
|
||||
@@ -142,10 +142,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchCountFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> NSNumber? {
|
||||
public func fetchCountFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> NSNumber? {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
return self.bridgeToSwift.mainContext.fetchCount(from, fetchClauses)
|
||||
@@ -160,10 +160,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchObjectIDFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
||||
public func fetchObjectIDFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
return self.bridgeToSwift.mainContext.fetchObjectID(from, fetchClauses)
|
||||
@@ -178,10 +178,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func fetchObjectIDsFrom(from: CSFrom, fetchClauses: [CSFetchClause]) -> [NSManagedObjectID]? {
|
||||
public func fetchObjectIDsFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [NSManagedObjectID]? {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
return self.bridgeToSwift.mainContext.fetchObjectIDs(from, fetchClauses)
|
||||
@@ -199,10 +199,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func queryValueFrom(from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
return self.bridgeToSwift.mainContext.queryValue(from, selectClause, queryClauses)
|
||||
@@ -220,10 +220,10 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func queryAttributesFrom(from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
|
||||
CoreStore.assert(
|
||||
NSThread.isMainThread(),
|
||||
Thread.isMainThread,
|
||||
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
|
||||
)
|
||||
return self.bridgeToSwift.mainContext.queryAttributes(from, selectClause, queryClauses)
|
||||
|
||||
@@ -36,7 +36,7 @@ public extension CSDataStack {
|
||||
- parameter closure: the block where creates, updates, and deletes can be made to the transaction. Transaction blocks are executed serially in a background queue, and all changes are made from a concurrent `NSManagedObjectContext`.
|
||||
*/
|
||||
@objc
|
||||
public func beginAsynchronous(closure: (transaction: CSAsynchronousDataTransaction) -> Void) {
|
||||
public func beginAsynchronous(_ closure: (transaction: CSAsynchronousDataTransaction) -> Void) {
|
||||
|
||||
return self.bridgeToSwift.beginAsynchronous { (transaction) in
|
||||
|
||||
@@ -51,7 +51,7 @@ public extension CSDataStack {
|
||||
- returns: a `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
@objc
|
||||
public func beginSynchronous(closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? {
|
||||
public func beginSynchronous(_ closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? {
|
||||
|
||||
return bridge {
|
||||
|
||||
@@ -86,7 +86,7 @@ public extension CSDataStack {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func beginUnsafeWithSupportsUndo(supportsUndo: Bool) -> CSUnsafeDataTransaction {
|
||||
public func beginUnsafeWithSupportsUndo(_ supportsUndo: Bool) -> CSUnsafeDataTransaction {
|
||||
|
||||
return bridge {
|
||||
|
||||
|
||||
@@ -54,12 +54,12 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter versionChain: the version strings that indicate the sequence of model versions to be used as the order for progressive migrations. If not specified, will default to a non-migrating data stack.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(modelName: String?, bundle: NSBundle?, versionChain: [String]?) {
|
||||
public convenience init(modelName: String?, bundle: Bundle?, versionChain: [String]?) {
|
||||
|
||||
self.init(
|
||||
DataStack(
|
||||
modelName: modelName ?? DataStack.applicationName,
|
||||
bundle: bundle ?? NSBundle.mainBundle(),
|
||||
bundle: bundle ?? Bundle.main,
|
||||
migrationChain: versionChain.flatMap { MigrationChain($0) } ?? nil
|
||||
)
|
||||
)
|
||||
@@ -73,12 +73,12 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter versionTree: the version strings that indicate the sequence of model versions to be used as the order for progressive migrations. If not specified, will default to a non-migrating data stack.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(modelName: String?, bundle: NSBundle?, versionTree: [String: String]?) {
|
||||
public convenience init(modelName: String?, bundle: Bundle?, versionTree: [String: String]?) {
|
||||
|
||||
self.init(
|
||||
DataStack(
|
||||
modelName: modelName ?? DataStack.applicationName,
|
||||
bundle: bundle ?? NSBundle.mainBundle(),
|
||||
bundle: bundle ?? Bundle.main,
|
||||
migrationChain: versionTree.flatMap { MigrationChain($0) } ?? nil
|
||||
)
|
||||
)
|
||||
@@ -142,7 +142,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` class for the given entity name, or `nil` if not found
|
||||
*/
|
||||
@objc
|
||||
public func entityClassWithName(name: String) -> NSManagedObject.Type? {
|
||||
public func entityClassWithName(_ name: String) -> NSManagedObject.Type? {
|
||||
|
||||
return self.bridgeToSwift.entityTypesByName[name]
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
Returns the `NSEntityDescription` for the specified `NSManagedObject` subclass from stack's model.
|
||||
*/
|
||||
@objc
|
||||
public func entityDescriptionForClass(type: NSManagedObject.Type) -> NSEntityDescription? {
|
||||
public func entityDescriptionForClass(_ type: NSManagedObject.Type) -> NSEntityDescription? {
|
||||
|
||||
return self.bridgeToSwift.entityDescriptionForType(type)
|
||||
}
|
||||
@@ -166,11 +166,11 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `CSInMemoryStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
public func addInMemoryStorageAndWaitAndReturnError(error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
public func addInMemoryStorageAndWaitAndReturnError(_ error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
try self.bridgeToSwift.addStorageAndWait(InMemoryStore)
|
||||
try self.bridgeToSwift.addStorageAndWait(InMemoryStore.self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,11 +184,11 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `CSSQLiteStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
public func addSQLiteStorageAndWaitAndReturnError(error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
public func addSQLiteStorageAndWaitAndReturnError(_ error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
try self.bridgeToSwift.addStorageAndWait(SQLiteStore)
|
||||
try self.bridgeToSwift.addStorageAndWait(SQLiteStore.self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `CSInMemoryStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
public func addInMemoryStorageAndWait(storage: CSInMemoryStore, error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
public func addInMemoryStorageAndWait(_ storage: CSInMemoryStore, error: NSErrorPointer) -> CSInMemoryStore? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
@@ -228,7 +228,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `CSSQLiteStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
public func addSQLiteStorageAndWait(storage: CSSQLiteStore, error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
public func addSQLiteStorageAndWait(_ storage: CSSQLiteStore, error: NSErrorPointer) -> CSSQLiteStore? {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
@@ -244,7 +244,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
return ObjectIdentifier(self.bridgeToSwift).hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSDataStack else {
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSError else {
|
||||
|
||||
@@ -77,53 +77,53 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
return swift
|
||||
}
|
||||
|
||||
func createSwiftObject(error: CSError) -> CoreStoreError {
|
||||
func createSwiftObject(_ error: CSError) -> CoreStoreError {
|
||||
|
||||
guard error.domain == CoreStoreErrorDomain else {
|
||||
|
||||
return .InternalError(NSError: self)
|
||||
return .internalError(NSError: self)
|
||||
}
|
||||
|
||||
guard let code = CoreStoreErrorCode(rawValue: error.code) else {
|
||||
|
||||
return .Unknown
|
||||
return .unknown
|
||||
}
|
||||
|
||||
let info = error.userInfo
|
||||
switch code {
|
||||
|
||||
case .UnknownError:
|
||||
return .Unknown
|
||||
case .unknownError:
|
||||
return .unknown
|
||||
|
||||
case .DifferentPersistentStoreExistsAtURL:
|
||||
guard case let existingPersistentStoreURL as NSURL = info["existingPersistentStoreURL"] else {
|
||||
case .differentPersistentStoreExistsAtURL:
|
||||
guard case let existingPersistentStoreURL as URL = info["existingPersistentStoreURL"] else {
|
||||
|
||||
return .Unknown
|
||||
return .unknown
|
||||
}
|
||||
return .DifferentStorageExistsAtURL(existingPersistentStoreURL: existingPersistentStoreURL)
|
||||
return .differentStorageExistsAtURL(existingPersistentStoreURL: existingPersistentStoreURL)
|
||||
|
||||
case .MappingModelNotFound:
|
||||
guard let localStoreURL = info["localStoreURL"] as? NSURL,
|
||||
case .mappingModelNotFound:
|
||||
guard let localStoreURL = info["localStoreURL"] as? URL,
|
||||
let targetModel = info["targetModel"] as? NSManagedObjectModel,
|
||||
let targetModelVersion = info["targetModelVersion"] as? String else {
|
||||
|
||||
return .Unknown
|
||||
return .unknown
|
||||
}
|
||||
return .MappingModelNotFound(localStoreURL: localStoreURL, targetModel: targetModel, targetModelVersion: targetModelVersion)
|
||||
return .mappingModelNotFound(localStoreURL: localStoreURL, targetModel: targetModel, targetModelVersion: targetModelVersion)
|
||||
|
||||
case .ProgressiveMigrationRequired:
|
||||
guard let localStoreURL = info["localStoreURL"] as? NSURL else {
|
||||
case .progressiveMigrationRequired:
|
||||
guard let localStoreURL = info["localStoreURL"] as? URL else {
|
||||
|
||||
return .Unknown
|
||||
return .unknown
|
||||
}
|
||||
return .ProgressiveMigrationRequired(localStoreURL: localStoreURL)
|
||||
return .progressiveMigrationRequired(localStoreURL: localStoreURL)
|
||||
|
||||
case .InternalError:
|
||||
case .internalError:
|
||||
guard case let NSError as NSError = info["NSError"] else {
|
||||
|
||||
return .Unknown
|
||||
return .unknown
|
||||
}
|
||||
return .InternalError(NSError: NSError)
|
||||
return .internalError(NSError: NSError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,32 +143,32 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
let info: [NSObject: AnyObject]
|
||||
switch swiftValue {
|
||||
|
||||
case .Unknown:
|
||||
code = .UnknownError
|
||||
case .unknown:
|
||||
code = .unknownError
|
||||
info = [:]
|
||||
|
||||
case .DifferentStorageExistsAtURL(let existingPersistentStoreURL):
|
||||
code = .DifferentPersistentStoreExistsAtURL
|
||||
case .differentStorageExistsAtURL(let existingPersistentStoreURL):
|
||||
code = .differentPersistentStoreExistsAtURL
|
||||
info = [
|
||||
"existingPersistentStoreURL": existingPersistentStoreURL
|
||||
]
|
||||
|
||||
case .MappingModelNotFound(let localStoreURL, let targetModel, let targetModelVersion):
|
||||
code = .MappingModelNotFound
|
||||
case .mappingModelNotFound(let localStoreURL, let targetModel, let targetModelVersion):
|
||||
code = .mappingModelNotFound
|
||||
info = [
|
||||
"localStoreURL": localStoreURL,
|
||||
"targetModel": targetModel,
|
||||
"targetModelVersion": targetModelVersion
|
||||
]
|
||||
|
||||
case .ProgressiveMigrationRequired(let localStoreURL):
|
||||
code = .ProgressiveMigrationRequired
|
||||
case .progressiveMigrationRequired(let localStoreURL):
|
||||
code = .progressiveMigrationRequired
|
||||
info = [
|
||||
"localStoreURL": localStoreURL
|
||||
]
|
||||
|
||||
case .InternalError(let NSError):
|
||||
code = .InternalError
|
||||
case .internalError(let NSError):
|
||||
code = .internalError
|
||||
info = [
|
||||
"NSError": NSError
|
||||
]
|
||||
@@ -203,27 +203,27 @@ public enum CSErrorCode: Int {
|
||||
/**
|
||||
A failure occured because of an unknown error.
|
||||
*/
|
||||
case UnknownError
|
||||
case unknownError
|
||||
|
||||
/**
|
||||
The `NSPersistentStore` could note be initialized because another store existed at the specified `NSURL`.
|
||||
*/
|
||||
case DifferentPersistentStoreExistsAtURL
|
||||
case differentPersistentStoreExistsAtURL
|
||||
|
||||
/**
|
||||
An `NSMappingModel` could not be found for a specific source and destination model versions.
|
||||
*/
|
||||
case MappingModelNotFound
|
||||
case mappingModelNotFound
|
||||
|
||||
/**
|
||||
Progressive migrations are disabled for a store, but an `NSMappingModel` could not be found for a specific source and destination model versions.
|
||||
*/
|
||||
case ProgressiveMigrationRequired
|
||||
case progressiveMigrationRequired
|
||||
|
||||
/**
|
||||
An internal SDK call failed with the specified "NSError" userInfo key.
|
||||
*/
|
||||
case InternalError
|
||||
case internalError
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ extension CoreStoreError: CoreStoreSwiftType {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
internal extension ErrorType {
|
||||
internal extension ErrorProtocol {
|
||||
|
||||
internal var bridgeToSwift: CoreStoreError {
|
||||
|
||||
@@ -250,7 +250,7 @@ internal extension ErrorType {
|
||||
|
||||
case let error as CoreStoreError: return error
|
||||
case let error as CSError: return error.bridgeToSwift
|
||||
default: return .Unknown
|
||||
default: return .unknown
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public final class CSGroupBy: NSObject, CSQueryClause, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSGroupBy else {
|
||||
|
||||
@@ -94,7 +94,7 @@ public final class CSGroupBy: NSObject, CSQueryClause, CoreStoreObjectiveCType {
|
||||
// MARK: CSQueryClause
|
||||
|
||||
@objc
|
||||
public func applyToFetchRequest(fetchRequest: NSFetchRequest) {
|
||||
public func applyToFetchRequest(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) {
|
||||
|
||||
self.bridgeToSwift.applyToFetchRequest(fetchRequest)
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public final class CSInMemoryStore: NSObject, CSStorageInterface, CoreStoreObjec
|
||||
return ObjectIdentifier(self.bridgeToSwift).hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSInMemoryStore else {
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public final class CSInto: NSObject, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSInto else {
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified index, or `nil` if out of bounds
|
||||
*/
|
||||
@objc
|
||||
public func objectAtSafeIndex(index: Int) -> AnyObject? {
|
||||
public func objectAtSafeIndex(_ index: Int) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift[safeIndex: index]
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified section and item index
|
||||
*/
|
||||
@objc
|
||||
public func objectAtSectionIndex(sectionIndex: Int, itemIndex: Int) -> AnyObject {
|
||||
public func objectAtSectionIndex(_ sectionIndex: Int, itemIndex: Int) -> AnyObject {
|
||||
|
||||
return self.bridgeToSwift[sectionIndex, itemIndex]
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified section and item index, or `nil` if out of bounds
|
||||
*/
|
||||
@objc
|
||||
public func objectAtSafeSectionIndex(sectionIndex: Int, safeItemIndex itemIndex: Int) -> AnyObject? {
|
||||
public func objectAtSafeSectionIndex(_ sectionIndex: Int, safeItemIndex itemIndex: Int) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift[safeSectionIndex: sectionIndex, safeItemIndex: itemIndex]
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified index path
|
||||
*/
|
||||
@objc
|
||||
public func objectAtIndexPath(indexPath: NSIndexPath) -> AnyObject {
|
||||
public func objectAtIndexPath(_ indexPath: IndexPath) -> AnyObject {
|
||||
|
||||
return self.bridgeToSwift[indexPath]
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: the `NSManagedObject` at the specified index path, or `nil` if out of bounds
|
||||
*/
|
||||
@objc
|
||||
public func objectAtSafeIndexPath(indexPath: NSIndexPath) -> AnyObject? {
|
||||
public func objectAtSafeIndexPath(_ indexPath: IndexPath) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift[safeIndexPath: indexPath]
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func hasObjectsInSection(section: Int) -> Bool {
|
||||
public func hasObjectsInSection(_ section: Int) -> Bool {
|
||||
|
||||
return self.bridgeToSwift.hasObjectsInSection(section)
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func objectsInSection(section: Int) -> [NSManagedObject] {
|
||||
public func objectsInSection(_ section: Int) -> [NSManagedObject] {
|
||||
|
||||
return self.bridgeToSwift.objectsInSection(section)
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func numberOfObjectsInSection(section: Int) -> Int {
|
||||
public func numberOfObjectsInSection(_ section: Int) -> Int {
|
||||
|
||||
return self.bridgeToSwift.numberOfObjectsInSection(section)
|
||||
}
|
||||
@@ -236,7 +236,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func sectionInfoAtIndex(section: Int) -> NSFetchedResultsSectionInfo {
|
||||
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
|
||||
|
||||
return self.bridgeToSwift.sectionInfoAtIndex(section)
|
||||
}
|
||||
@@ -275,7 +275,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func targetSectionForSectionIndexTitle(title title: String, index: Int) -> Int {
|
||||
public func targetSectionForSectionIndexTitle(title: String, index: Int) -> Int {
|
||||
|
||||
return self.bridgeToSwift.targetSectionForSectionIndex(title: title, index: index)
|
||||
}
|
||||
@@ -300,7 +300,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func indexOf(object: NSManagedObject) -> NSNumber? {
|
||||
public func indexOf(_ object: NSManagedObject) -> NSNumber? {
|
||||
|
||||
return self.bridgeToSwift.indexOf(object)
|
||||
}
|
||||
@@ -313,7 +313,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func indexPathOf(object: NSManagedObject) -> NSIndexPath? {
|
||||
public func indexPathOf(_ object: NSManagedObject) -> IndexPath? {
|
||||
|
||||
return self.bridgeToSwift.indexPathOf(object)
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter observer: a `CSListObserver` to send change notifications to
|
||||
*/
|
||||
@objc
|
||||
public func addListObserver(observer: CSListObserver) {
|
||||
public func addListObserver(_ observer: CSListObserver) {
|
||||
|
||||
let swift = self.bridgeToSwift
|
||||
swift.unregisterObserver(observer)
|
||||
@@ -369,7 +369,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
- parameter observer: a `CSListObjectObserver` to send change notifications to
|
||||
*/
|
||||
public func addListObjectObserver(observer: CSListObjectObserver) {
|
||||
public func addListObjectObserver(_ observer: CSListObjectObserver) {
|
||||
|
||||
let swift = self.bridgeToSwift
|
||||
swift.unregisterObserver(observer)
|
||||
@@ -425,7 +425,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter observer: a `CSListSectionObserver` to send change notifications to
|
||||
*/
|
||||
@objc
|
||||
public func addListSectionObserver(observer: CSListSectionObserver) {
|
||||
public func addListSectionObserver(_ observer: CSListSectionObserver) {
|
||||
|
||||
let swift = self.bridgeToSwift
|
||||
swift.unregisterObserver(observer)
|
||||
@@ -488,7 +488,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter observer: a `CSListObserver` to unregister notifications to
|
||||
*/
|
||||
@objc
|
||||
public func removeListObserver(observer: CSListObserver) {
|
||||
public func removeListObserver(_ observer: CSListObserver) {
|
||||
|
||||
self.bridgeToSwift.unregisterObserver(observer)
|
||||
}
|
||||
@@ -513,11 +513,11 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. Note that only specified clauses will be changed; unspecified clauses will use previous values.
|
||||
*/
|
||||
@objc
|
||||
public func refetch(fetchClauses: [CSFetchClause]) {
|
||||
public func refetch(_ fetchClauses: [CSFetchClause]) {
|
||||
|
||||
self.bridgeToSwift.refetch { (fetchRequest) in
|
||||
self.bridgeToSwift.refetch { (fetchRequest: NSFetchRequest<NSManagedObject>) in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest.cs_dynamicCast()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSListMonitor else {
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public protocol CSListObserver: class, AnyObject {
|
||||
- parameter monitor: the `CSListMonitor` monitoring the list being observed
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitorWillChange(monitor: CSListMonitor)
|
||||
optional func listMonitorWillChange(_ monitor: CSListMonitor)
|
||||
|
||||
/**
|
||||
Handles processing right after a change to the observed list occurs
|
||||
@@ -59,7 +59,7 @@ public protocol CSListObserver: class, AnyObject {
|
||||
- parameter monitor: the `CSListMonitor` monitoring the object being observed
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitorDidChange(monitor: CSListMonitor)
|
||||
optional func listMonitorDidChange(_ monitor: CSListMonitor)
|
||||
|
||||
/**
|
||||
This method is broadcast from within the `CSListMonitor`'s `-refetchWithFetchClauses:` method to let observers prepare for the internal `NSFetchedResultsController`'s pending change to its predicate, sort descriptors, etc. Note that the actual refetch will happen after the `NSFetchedResultsController`'s last `-controllerDidChangeContent:` notification completes.
|
||||
@@ -67,7 +67,7 @@ public protocol CSListObserver: class, AnyObject {
|
||||
- parameter monitor: the `CSListMonitor` monitoring the object being observed
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitorWillRefetch(monitor: CSListMonitor)
|
||||
optional func listMonitorWillRefetch(_ monitor: CSListMonitor)
|
||||
|
||||
/**
|
||||
After the `CSListMonitor`'s `-refetchWithFetchClauses:` method is called, this method is broadcast after the `NSFetchedResultsController`'s last `-controllerDidChangeContent:` notification completes.
|
||||
@@ -75,7 +75,7 @@ public protocol CSListObserver: class, AnyObject {
|
||||
- parameter monitor: the `CSListMonitor` monitoring the object being observed
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitorDidRefetch(monitor: CSListMonitor)
|
||||
optional func listMonitorDidRefetch(_ monitor: CSListMonitor)
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
- parameter indexPath: the new `NSIndexPath` for the inserted object
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(monitor: CSListMonitor, didInsertObject object: AnyObject, toIndexPath indexPath: NSIndexPath)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didInsertObject object: AnyObject, toIndexPath indexPath: IndexPath)
|
||||
|
||||
/**
|
||||
Notifies that an object was deleted from the specified `NSIndexPath` in the list
|
||||
@@ -113,7 +113,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
- parameter indexPath: the `NSIndexPath` for the deleted object
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(monitor: CSListMonitor, didDeleteObject object: AnyObject, fromIndexPath indexPath: NSIndexPath)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didDeleteObject object: AnyObject, fromIndexPath indexPath: IndexPath)
|
||||
|
||||
/**
|
||||
Notifies that an object at the specified `NSIndexPath` was updated
|
||||
@@ -123,7 +123,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
- parameter indexPath: the `NSIndexPath` for the updated object
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(monitor: CSListMonitor, didUpdateObject object: AnyObject, atIndexPath indexPath: NSIndexPath)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didUpdateObject object: AnyObject, atIndexPath indexPath: IndexPath)
|
||||
|
||||
/**
|
||||
Notifies that an object's index changed
|
||||
@@ -134,7 +134,7 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
- parameter toIndexPath: the new `NSIndexPath` for the moved object
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(monitor: CSListMonitor, didMoveObject object: AnyObject, fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didMoveObject object: AnyObject, fromIndexPath: IndexPath, toIndexPath: IndexPath)
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public protocol CSListSectionObserver: CSListObjectObserver {
|
||||
- parameter sectionIndex: the new section index for the new section
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(monitor: CSListMonitor, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int)
|
||||
|
||||
/**
|
||||
Notifies that a section was inserted at the specified index
|
||||
@@ -173,7 +173,7 @@ public protocol CSListSectionObserver: CSListObjectObserver {
|
||||
- parameter sectionIndex: the previous section index for the deleted section
|
||||
*/
|
||||
@objc
|
||||
optional func listMonitor(monitor: CSListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
|
||||
optional func listMonitor(_ monitor: CSListMonitor, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public var migrationTypes: [CSMigrationType]? {
|
||||
|
||||
guard case .Success(let migrationTypes) = self.bridgeToSwift else {
|
||||
guard case .success(let migrationTypes) = self.bridgeToSwift else {
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public var error: NSError? {
|
||||
|
||||
guard case .Failure(let error) = self.bridgeToSwift else {
|
||||
guard case .failure(let error) = self.bridgeToSwift else {
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -90,14 +90,14 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter failure: the block to execute on failure. The block passes an `NSError` argument that pertains to the actual error.
|
||||
*/
|
||||
@objc
|
||||
public func handleSuccess(@noescape success: (migrationTypes: [CSMigrationType]) -> Void, @noescape failure: (error: NSError) -> Void) {
|
||||
public func handleSuccess(@noescape _ success: (migrationTypes: [CSMigrationType]) -> Void, @noescape failure: (error: NSError) -> Void) {
|
||||
|
||||
switch self.bridgeToSwift {
|
||||
|
||||
case .Success(let migrationTypes):
|
||||
case .success(let migrationTypes):
|
||||
success(migrationTypes: migrationTypes.map { $0.bridgeToObjectiveC })
|
||||
|
||||
case .Failure(let error):
|
||||
case .failure(let error):
|
||||
failure(error: error.bridgeToObjectiveC)
|
||||
}
|
||||
}
|
||||
@@ -110,9 +110,9 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter success: the block to execute on success. The block passes an array of `CSMigrationType`s that indicates the migration steps completed.
|
||||
*/
|
||||
@objc
|
||||
public func handleSuccess(@noescape success: (migrationTypes: [CSMigrationType]) -> Void) {
|
||||
public func handleSuccess(@noescape _ success: (migrationTypes: [CSMigrationType]) -> Void) {
|
||||
|
||||
guard case .Success(let migrationTypes) = self.bridgeToSwift else {
|
||||
guard case .success(let migrationTypes) = self.bridgeToSwift else {
|
||||
|
||||
return
|
||||
}
|
||||
@@ -127,9 +127,9 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter failure: the block to execute on failure. The block passes an `NSError` argument that pertains to the actual error.
|
||||
*/
|
||||
@objc
|
||||
public func handleFailure(@noescape failure: (error: NSError) -> Void) {
|
||||
public func handleFailure(@noescape _ failure: (error: NSError) -> Void) {
|
||||
|
||||
guard case .Failure(let error) = self.bridgeToSwift else {
|
||||
guard case .failure(let error) = self.bridgeToSwift else {
|
||||
|
||||
return
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSMigrationResult else {
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public final class CSMigrationType: NSObject, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSMigrationType else {
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
- parameter observer: an `CSObjectObserver` to send change notifications to
|
||||
*/
|
||||
public func addObjectObserver(observer: CSObjectObserver) {
|
||||
public func addObjectObserver(_ observer: CSObjectObserver) {
|
||||
|
||||
let swift = self.bridgeToSwift
|
||||
swift.unregisterObserver(observer)
|
||||
@@ -94,7 +94,7 @@ public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
- parameter observer: an `CSObjectObserver` to unregister notifications to
|
||||
*/
|
||||
public func removeObjectObserver(observer: CSObjectObserver) {
|
||||
public func removeObjectObserver(_ observer: CSObjectObserver) {
|
||||
|
||||
self.bridgeToSwift.unregisterObserver(observer)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSObjectMonitor else {
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public protocol CSObjectObserver: class, AnyObject {
|
||||
- parameter object: the `NSManagedObject` instance being observed
|
||||
*/
|
||||
@objc
|
||||
optional func objectMonitor(monitor: CSObjectMonitor, willUpdateObject object: AnyObject)
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, willUpdateObject object: AnyObject)
|
||||
|
||||
/**
|
||||
Handles processing right after a change to the observed `object` occurs
|
||||
@@ -60,7 +60,7 @@ public protocol CSObjectObserver: class, AnyObject {
|
||||
- parameter changedPersistentKeys: an `NSSet` of key paths for the attributes that were changed. Note that `changedPersistentKeys` only contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported.
|
||||
*/
|
||||
@objc
|
||||
optional func objectMonitor(monitor: CSObjectMonitor, didUpdateObject object: AnyObject, changedPersistentKeys: Set<String>)
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, didUpdateObject object: AnyObject, changedPersistentKeys: Set<String>)
|
||||
|
||||
/**
|
||||
Handles processing right after `object` is deleted
|
||||
@@ -69,7 +69,7 @@ public protocol CSObjectObserver: class, AnyObject {
|
||||
- parameter object: the `NSManagedObject` instance being observed
|
||||
*/
|
||||
@objc
|
||||
optional func objectMonitor(monitor: CSObjectMonitor, didDeleteObject object: AnyObject)
|
||||
optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: AnyObject)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
|
||||
The list of sort descriptors
|
||||
*/
|
||||
@objc
|
||||
public var sortDescriptors: [NSSortDescriptor] {
|
||||
public var sortDescriptors: [SortDescriptor] {
|
||||
|
||||
return self.bridgeToSwift.sortDescriptors
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
|
||||
- parameter sortDescriptor: a `NSSortDescriptor`
|
||||
*/
|
||||
@objc
|
||||
public convenience init(sortDescriptor: NSSortDescriptor) {
|
||||
public convenience init(sortDescriptor: SortDescriptor) {
|
||||
|
||||
self.init(OrderBy(sortDescriptor))
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
|
||||
- parameter sortDescriptors: an array of `NSSortDescriptor`s
|
||||
*/
|
||||
@objc
|
||||
public convenience init(sortDescriptors: [NSSortDescriptor]) {
|
||||
public convenience init(sortDescriptors: [SortDescriptor]) {
|
||||
|
||||
self.init(OrderBy(sortDescriptors))
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSOrderBy else {
|
||||
|
||||
@@ -104,7 +104,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
|
||||
// MARK: CSFetchClause, CSQueryClause, CSDeleteClause
|
||||
|
||||
@objc
|
||||
public func applyToFetchRequest(fetchRequest: NSFetchRequest) {
|
||||
public func applyToFetchRequest(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) {
|
||||
|
||||
self.bridgeToSwift.applyToFetchRequest(fetchRequest)
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
- parameter localStorageOptions: When the `CSSQLiteStore` is passed to the `CSDataStack`'s `addStorage()` methods, tells the `CSDataStack` how to setup the persistent store. Defaults to `CSLocalStorageOptionsNone`.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(fileURL: NSURL, configuration: String?, mappingModelBundles: [NSBundle]?, localStorageOptions: Int) {
|
||||
public convenience init(fileURL: URL, configuration: String?, mappingModelBundles: [Bundle]?, localStorageOptions: Int) {
|
||||
|
||||
self.init(
|
||||
SQLiteStore(
|
||||
fileURL: fileURL,
|
||||
configuration: configuration,
|
||||
mappingModelBundles: mappingModelBundles ?? NSBundle.allBundles(),
|
||||
mappingModelBundles: mappingModelBundles ?? Bundle.allBundles,
|
||||
localStorageOptions: LocalStorageOptions(rawValue: localStorageOptions)
|
||||
)
|
||||
)
|
||||
@@ -68,13 +68,13 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
- parameter localStorageOptions: When the `CSSQLiteStore` is passed to the `CSDataStack`'s `addStorage()` methods, tells the `CSDataStack` how to setup the persistent store. Defaults to `[CSLocalStorageOptions none]`.
|
||||
*/
|
||||
@objc
|
||||
public convenience init(fileName: String, configuration: String?, mappingModelBundles: [NSBundle]?, localStorageOptions: Int) {
|
||||
public convenience init(fileName: String, configuration: String?, mappingModelBundles: [Bundle]?, localStorageOptions: Int) {
|
||||
|
||||
self.init(
|
||||
SQLiteStore(
|
||||
fileName: fileName,
|
||||
configuration: configuration,
|
||||
mappingModelBundles: mappingModelBundles ?? NSBundle.allBundles(),
|
||||
mappingModelBundles: mappingModelBundles ?? Bundle.allBundles,
|
||||
localStorageOptions: LocalStorageOptions(rawValue: localStorageOptions)
|
||||
)
|
||||
)
|
||||
@@ -98,16 +98,16 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
The `NSURL` that points to the SQLite file
|
||||
*/
|
||||
@objc
|
||||
public var fileURL: NSURL {
|
||||
public var fileURL: URL {
|
||||
|
||||
return self.bridgeToSwift.fileURL
|
||||
return self.bridgeToSwift.fileURL as URL
|
||||
}
|
||||
|
||||
/**
|
||||
The `NSBundle`s from which to search mapping models for migrations
|
||||
*/
|
||||
@objc
|
||||
public var mappingModelBundles: [NSBundle] {
|
||||
public var mappingModelBundles: [Bundle] {
|
||||
|
||||
return self.bridgeToSwift.mappingModelBundles
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
Called by the `CSDataStack` to perform actual deletion of the store file from disk. Do not call directly! The `sourceModel` argument is a hint for the existing store's model version. For `CSSQLiteStore`, this converts the database's WAL journaling mode to DELETE before deleting the file.
|
||||
*/
|
||||
@objc
|
||||
public func eraseStorageAndWait(soureModel soureModel: NSManagedObjectModel, error: NSErrorPointer) -> Bool {
|
||||
public func eraseStorageAndWait(soureModel: NSManagedObjectModel, error: NSErrorPointer) -> Bool {
|
||||
|
||||
return bridge(error) {
|
||||
|
||||
@@ -170,7 +170,7 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
return ObjectIdentifier(self.bridgeToSwift).hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSSQLiteStore else {
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class CSSaveResult: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public var hasChanges: Bool {
|
||||
|
||||
guard case .Success(let hasChanges) = self.bridgeToSwift else {
|
||||
guard case .success(let hasChanges) = self.bridgeToSwift else {
|
||||
|
||||
return false
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public final class CSSaveResult: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public var error: NSError? {
|
||||
|
||||
guard case .Failure(let error) = self.bridgeToSwift else {
|
||||
guard case .failure(let error) = self.bridgeToSwift else {
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -90,14 +90,14 @@ public final class CSSaveResult: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter failure: the block to execute on failure. The block passes an `NSError` argument that pertains to the actual error.
|
||||
*/
|
||||
@objc
|
||||
public func handleSuccess(@noescape success: (hasChanges: Bool) -> Void, @noescape failure: (error: NSError) -> Void) {
|
||||
public func handleSuccess(@noescape _ success: (hasChanges: Bool) -> Void, @noescape failure: (error: NSError) -> Void) {
|
||||
|
||||
switch self.bridgeToSwift {
|
||||
|
||||
case .Success(let hasChanges):
|
||||
case .success(let hasChanges):
|
||||
success(hasChanges: hasChanges)
|
||||
|
||||
case .Failure(let error):
|
||||
case .failure(let error):
|
||||
failure(error: error.bridgeToObjectiveC)
|
||||
}
|
||||
}
|
||||
@@ -110,9 +110,9 @@ public final class CSSaveResult: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter success: the block to execute on success. The block passes a `BOOL` argument that indicates if there were any changes made.
|
||||
*/
|
||||
@objc
|
||||
public func handleSuccess(@noescape success: (hasChanges: Bool) -> Void) {
|
||||
public func handleSuccess(@noescape _ success: (hasChanges: Bool) -> Void) {
|
||||
|
||||
guard case .Success(let hasChanges) = self.bridgeToSwift else {
|
||||
guard case .success(let hasChanges) = self.bridgeToSwift else {
|
||||
|
||||
return
|
||||
}
|
||||
@@ -127,9 +127,9 @@ public final class CSSaveResult: NSObject, CoreStoreObjectiveCType {
|
||||
- parameter failure: the block to execute on failure. The block passes an `NSError` argument that pertains to the actual error.
|
||||
*/
|
||||
@objc
|
||||
public func handleFailure(@noescape failure: (error: NSError) -> Void) {
|
||||
public func handleFailure(@noescape _ failure: (error: NSError) -> Void) {
|
||||
|
||||
guard case .Failure(let error) = self.bridgeToSwift else {
|
||||
guard case .failure(let error) = self.bridgeToSwift else {
|
||||
|
||||
return
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public final class CSSaveResult: NSObject, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSSaveResult else {
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
|
||||
*/
|
||||
@objc
|
||||
public static func keyPath(sectionKeyPath: KeyPath) -> CSSectionBy {
|
||||
public static func keyPath(_ sectionKeyPath: KeyPath) -> CSSectionBy {
|
||||
|
||||
return self.init(SectionBy(sectionKeyPath))
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
|
||||
*/
|
||||
@objc
|
||||
public static func keyPath(sectionKeyPath: KeyPath, sectionIndexTransformer: (sectionName: String?) -> String?) -> CSSectionBy {
|
||||
public static func keyPath(_ sectionKeyPath: KeyPath, sectionIndexTransformer: (sectionName: String?) -> String?) -> CSSectionBy {
|
||||
|
||||
return self.init(SectionBy(sectionKeyPath, sectionIndexTransformer))
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
@objc
|
||||
public convenience init(keyPath: KeyPath) {
|
||||
|
||||
self.init(.Attribute(keyPath))
|
||||
self.init(.attribute(keyPath))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,9 +67,9 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the average value of an attribute
|
||||
*/
|
||||
@objc
|
||||
public static func average(keyPath: KeyPath, `as` alias: KeyPath?) -> CSSelectTerm {
|
||||
public static func average(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.Average(keyPath, As: alias))
|
||||
return self.init(.average(keyPath, As: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,9 +85,9 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
*/
|
||||
@objc
|
||||
public static func count(keyPath: KeyPath, `as` alias: KeyPath?) -> CSSelectTerm {
|
||||
public static func count(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.Count(keyPath, As: alias))
|
||||
return self.init(.count(keyPath, As: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,9 +103,9 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the maximum value for an attribute
|
||||
*/
|
||||
@objc
|
||||
public static func maximum(keyPath: KeyPath, `as` alias: KeyPath?) -> CSSelectTerm {
|
||||
public static func maximum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.Maximum(keyPath, As: alias))
|
||||
return self.init(.maximum(keyPath, As: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,9 +121,9 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the minimum value for an attribute
|
||||
*/
|
||||
@objc
|
||||
public static func minimum(keyPath: KeyPath, `as` alias: KeyPath?) -> CSSelectTerm {
|
||||
public static func minimum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.Minimum(keyPath, As: alias))
|
||||
return self.init(.minimum(keyPath, As: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,9 +139,9 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the sum value for an attribute
|
||||
*/
|
||||
@objc
|
||||
public static func sum(keyPath: KeyPath, `as` alias: KeyPath?) -> CSSelectTerm {
|
||||
public static func sum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
|
||||
|
||||
return self.init(.Sum(keyPath, As: alias))
|
||||
return self.init(.sum(keyPath, As: alias))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,9 +158,9 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
@objc
|
||||
public static func objectIDAs(alias: KeyPath? = nil) -> CSSelectTerm {
|
||||
public static func objectIDAs(_ alias: KeyPath? = nil) -> CSSelectTerm {
|
||||
|
||||
return self.init(.ObjectID(As: alias))
|
||||
return self.init(.objectID(As: alias))
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSSelectTerm else {
|
||||
|
||||
@@ -274,7 +274,7 @@ public final class CSSelect: NSObject {
|
||||
*/
|
||||
public convenience init(dateTerm: CSSelectTerm) {
|
||||
|
||||
self.init(Select<NSDate>(dateTerm.bridgeToSwift))
|
||||
self.init(Select<Date>(dateTerm.bridgeToSwift))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,7 +290,7 @@ public final class CSSelect: NSObject {
|
||||
*/
|
||||
public convenience init(dataTerm: CSSelectTerm) {
|
||||
|
||||
self.init(Select<NSData>(dataTerm.bridgeToSwift))
|
||||
self.init(Select<Data>(dataTerm.bridgeToSwift))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +306,7 @@ public final class CSSelect: NSObject {
|
||||
*/
|
||||
public convenience init(objectIDTerm: ()) {
|
||||
|
||||
self.init(Select<NSManagedObjectID>(.ObjectID()))
|
||||
self.init(Select<NSManagedObjectID>(.objectID()))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +320,7 @@ public final class CSSelect: NSObject {
|
||||
- parameter term: the `CSSelectTerm` specifying the attribute/aggregate value to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
public static func dictionaryForTerm(term: CSSelectTerm) -> CSSelect {
|
||||
public static func dictionaryForTerm(_ term: CSSelectTerm) -> CSSelect {
|
||||
|
||||
return self.init(Select<NSDictionary>(term.bridgeToSwift))
|
||||
}
|
||||
@@ -339,7 +339,7 @@ public final class CSSelect: NSObject {
|
||||
- parameter terms: the `CSSelectTerm`s specifying the attribute/aggregate values to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
public static func dictionaryForTerms(terms: [CSSelectTerm]) -> CSSelect {
|
||||
public static func dictionaryForTerms(_ terms: [CSSelectTerm]) -> CSSelect {
|
||||
|
||||
return self.init(Select<NSDictionary>(terms.map { $0.bridgeToSwift }))
|
||||
}
|
||||
@@ -353,7 +353,7 @@ public final class CSSelect: NSObject {
|
||||
^ self.selectTerms.map { $0.hashValue }.reduce(0, combine: ^)
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSSelect else {
|
||||
|
||||
@@ -381,7 +381,7 @@ public final class CSSelect: NSObject {
|
||||
|
||||
public init<T: SelectResultType>(_ swiftValue: Select<T>) {
|
||||
|
||||
self.attributeType = .UndefinedAttributeType
|
||||
self.attributeType = .undefinedAttributeType
|
||||
self.selectTerms = swiftValue.selectTerms
|
||||
self.bridgeToSwift = swiftValue
|
||||
super.init()
|
||||
|
||||
@@ -76,7 +76,7 @@ public final class CSSetupResult: NSObject {
|
||||
- parameter failure: the block to execute on failure. The block passes an `NSError` argument that pertains to the actual error.
|
||||
*/
|
||||
@objc
|
||||
public func handleSuccess(@noescape success: (storage: CSStorageInterface) -> Void, @noescape failure: (error: NSError) -> Void) {
|
||||
public func handleSuccess(@noescape _ success: (storage: CSStorageInterface) -> Void, @noescape failure: (error: NSError) -> Void) {
|
||||
|
||||
if let storage = self.storage {
|
||||
|
||||
@@ -96,7 +96,7 @@ public final class CSSetupResult: NSObject {
|
||||
- parameter success: the block to execute on success. The block passes a `BOOL` argument that indicates if there were any changes made.
|
||||
*/
|
||||
@objc
|
||||
public func handleSuccess(@noescape success: (storage: CSStorageInterface) -> Void) {
|
||||
public func handleSuccess(@noescape _ success: (storage: CSStorageInterface) -> Void) {
|
||||
|
||||
guard let storage = self.storage else {
|
||||
|
||||
@@ -113,7 +113,7 @@ public final class CSSetupResult: NSObject {
|
||||
- parameter failure: the block to execute on failure. The block passes an `NSError` argument that pertains to the actual error.
|
||||
*/
|
||||
@objc
|
||||
public func handleFailure(@noescape failure: (error: NSError) -> Void) {
|
||||
public func handleFailure(@noescape _ failure: (error: NSError) -> Void) {
|
||||
|
||||
guard let error = self.error else {
|
||||
|
||||
@@ -134,7 +134,7 @@ public final class CSSetupResult: NSObject {
|
||||
return self.isSuccess.hashValue ^ self.error!.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSSetupResult else {
|
||||
|
||||
@@ -156,11 +156,11 @@ public final class CSSetupResult: NSObject {
|
||||
|
||||
switch swiftValue {
|
||||
|
||||
case .Success(let storage):
|
||||
case .success(let storage):
|
||||
self.storage = storage.bridgeToObjectiveC
|
||||
self.error = nil
|
||||
|
||||
case .Failure(let error):
|
||||
case .failure(let error):
|
||||
self.storage = nil
|
||||
self.error = error.bridgeToObjectiveC
|
||||
}
|
||||
|
||||
@@ -70,22 +70,22 @@ public enum CSLocalStorageOptions: Int {
|
||||
/**
|
||||
Tells the `DataStack` that the store should not be migrated or recreated, and should simply fail on model mismatch
|
||||
*/
|
||||
case None = 0
|
||||
case none = 0
|
||||
|
||||
/**
|
||||
Tells the `DataStack` to delete and recreate the store on model mismatch, otherwise exceptions will be thrown on failure instead
|
||||
*/
|
||||
case RecreateStoreOnModelMismatch = 1
|
||||
case recreateStoreOnModelMismatch = 1
|
||||
|
||||
/**
|
||||
Tells the `DataStack` to prevent progressive migrations for the store
|
||||
*/
|
||||
case PreventProgressiveMigration = 2
|
||||
case preventProgressiveMigration = 2
|
||||
|
||||
/**
|
||||
Tells the `DataStack` to allow lightweight migration for the store when added synchronously
|
||||
*/
|
||||
case AllowSynchronousLightweightMigration = 4
|
||||
case allowSynchronousLightweightMigration = 4
|
||||
}
|
||||
|
||||
|
||||
@@ -103,13 +103,13 @@ public protocol CSLocalStorage: CSStorageInterface {
|
||||
The `NSURL` that points to the store file
|
||||
*/
|
||||
@objc
|
||||
var fileURL: NSURL { get }
|
||||
var fileURL: URL { get }
|
||||
|
||||
/**
|
||||
The `NSBundle`s from which to search mapping models for migrations
|
||||
*/
|
||||
@objc
|
||||
var mappingModelBundles: [NSBundle] { get }
|
||||
var mappingModelBundles: [Bundle] { get }
|
||||
|
||||
/**
|
||||
Options that tell the `CSDataStack` how to setup the persistent store
|
||||
@@ -121,5 +121,5 @@ public protocol CSLocalStorage: CSStorageInterface {
|
||||
Called by the `CSDataStack` to perform actual deletion of the store file from disk. Do not call directly! The `sourceModel` argument is a hint for the existing store's model version. Implementers can use the `sourceModel` to perform necessary store operations. (SQLite stores for example, can convert WAL journaling mode to DELETE before deleting)
|
||||
*/
|
||||
@objc
|
||||
func eraseStorageAndWait(soureModel soureModel: NSManagedObjectModel, error: NSErrorPointer) -> Bool
|
||||
func eraseStorageAndWait(soureModel: NSManagedObjectModel, error: NSErrorPointer) -> Bool
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: a `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
|
||||
*/
|
||||
@objc
|
||||
public func beginSynchronous(closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? {
|
||||
public func beginSynchronous(_ closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? {
|
||||
|
||||
return bridge {
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- returns: a new `NSManagedObject` instance of the specified entity type.
|
||||
*/
|
||||
@objc
|
||||
public override func createInto(into: CSInto) -> AnyObject {
|
||||
public override func createInto(_ into: CSInto) -> AnyObject {
|
||||
|
||||
return self.bridgeToSwift.create(into.bridgeToSwift)
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public override func editObject(object: NSManagedObject?) -> AnyObject? {
|
||||
public override func editObject(_ object: NSManagedObject?) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(object)
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public override func editInto(into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
|
||||
|
||||
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
- parameter object: the `NSManagedObject` type to be deleted
|
||||
*/
|
||||
@objc
|
||||
public override func deleteObject(object: NSManagedObject?) {
|
||||
public override func deleteObject(_ object: NSManagedObject?) {
|
||||
|
||||
return self.bridgeToSwift.delete(object)
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
- parameter objects: the `NSManagedObject`s to be deleted
|
||||
*/
|
||||
public override func deleteObjects(objects: [NSManagedObject]) {
|
||||
public override func deleteObjects(_ objects: [NSManagedObject]) {
|
||||
|
||||
self.bridgeToSwift.delete(objects)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class CSTweak: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
The block to customize the `NSFetchRequest`
|
||||
*/
|
||||
@objc
|
||||
public var block: (fetchRequest: NSFetchRequest) -> Void {
|
||||
public var block: (fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Void {
|
||||
|
||||
return self.bridgeToSwift.closure
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public final class CSTweak: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
- parameter block: the block to customize the `NSFetchRequest`
|
||||
*/
|
||||
@objc
|
||||
public convenience init(block: (fetchRequest: NSFetchRequest) -> Void) {
|
||||
public convenience init(block: (fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Void) {
|
||||
|
||||
self.init(Tweak(block))
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public final class CSTweak: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
// MARK: CSFetchClause, CSQueryClause, CSDeleteClause
|
||||
|
||||
@objc
|
||||
public func applyToFetchRequest(fetchRequest: NSFetchRequest) {
|
||||
public func applyToFetchRequest(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) {
|
||||
|
||||
self.bridgeToSwift.applyToFetchRequest(fetchRequest)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
- parameter completion: the block executed after the save completes. Success or failure is reported by the `CSSaveResult` argument of the block.
|
||||
*/
|
||||
@objc
|
||||
public func commit(completion: ((result: CSSaveResult) -> Void)?) {
|
||||
public func commit(_ completion: ((result: CSSaveResult) -> Void)?) {
|
||||
|
||||
self.bridgeToSwift.commit { (result) in
|
||||
|
||||
@@ -110,7 +110,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
- parameter closure: the closure where changes can be made prior to the flush
|
||||
*/
|
||||
@objc
|
||||
public func flush(block: () -> Void) {
|
||||
public func flush(_ block: () -> Void) {
|
||||
|
||||
self.bridgeToSwift.flush {
|
||||
|
||||
@@ -142,7 +142,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func beginUnsafeWithSupportsUndo(supportsUndo: Bool) -> CSUnsafeDataTransaction {
|
||||
public func beginUnsafeWithSupportsUndo(_ supportsUndo: Bool) -> CSUnsafeDataTransaction {
|
||||
|
||||
return bridge {
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
The internal `NSPredicate` instance for the `Where` clause
|
||||
*/
|
||||
@objc
|
||||
public var predicate: NSPredicate {
|
||||
public var predicate: Predicate {
|
||||
|
||||
return self.bridgeToSwift.predicate
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
- parameter predicate: the `NSPredicate` for the fetch or query
|
||||
*/
|
||||
@objc
|
||||
public convenience init(predicate: NSPredicate) {
|
||||
public convenience init(predicate: Predicate) {
|
||||
|
||||
self.init(Where(predicate))
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
return self.bridgeToSwift.hashValue
|
||||
}
|
||||
|
||||
public override func isEqual(object: AnyObject?) -> Bool {
|
||||
public override func isEqual(_ object: AnyObject?) -> Bool {
|
||||
|
||||
guard let object = object as? CSWhere else {
|
||||
|
||||
@@ -141,7 +141,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
// MARK: CSFetchClause, CSQueryClause, CSDeleteClause
|
||||
|
||||
@objc
|
||||
public func applyToFetchRequest(fetchRequest: NSFetchRequest) {
|
||||
public func applyToFetchRequest(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) {
|
||||
|
||||
self.bridgeToSwift.applyToFetchRequest(fetchRequest)
|
||||
}
|
||||
|
||||
@@ -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>(@noescape _ closure: () -> 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>(@noescape _ closure: () -> 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>(@noescape _ closure: () 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(@noescape _ closure: () throws -> Void) throws {
|
||||
|
||||
do {
|
||||
|
||||
@@ -113,62 +113,62 @@ 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, @noescape _ closure: () throws -> T) -> T.ObjectiveCType? {
|
||||
|
||||
do {
|
||||
|
||||
let result = try closure()
|
||||
error.memory = nil
|
||||
error?.pointee = nil
|
||||
return result.bridgeToObjectiveC
|
||||
}
|
||||
catch let swiftError {
|
||||
|
||||
error.memory = swiftError.bridgeToObjectiveC
|
||||
error?.pointee = swiftError.bridgeToObjectiveC
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge(error: NSErrorPointer, @noescape _ closure: () throws -> Void) -> Bool {
|
||||
internal func bridge(_ error: NSErrorPointer, @noescape _ closure: () throws -> Void) -> Bool {
|
||||
|
||||
do {
|
||||
|
||||
try closure()
|
||||
error.memory = nil
|
||||
error?.pointee = nil
|
||||
return true
|
||||
}
|
||||
catch let swiftError {
|
||||
|
||||
error.memory = swiftError.bridgeToObjectiveC
|
||||
error?.pointee = swiftError.bridgeToObjectiveC
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge<T>(error: NSErrorPointer, @noescape _ closure: () throws -> T?) -> T? {
|
||||
internal func bridge<T>(_ error: NSErrorPointer, @noescape _ closure: () throws -> T?) -> T? {
|
||||
|
||||
do {
|
||||
|
||||
let result = try closure()
|
||||
error.memory = nil
|
||||
error?.pointee = nil
|
||||
return result
|
||||
}
|
||||
catch let swiftError {
|
||||
|
||||
error.memory = swiftError.bridgeToObjectiveC
|
||||
error?.pointee = swiftError.bridgeToObjectiveC
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge<T: CoreStoreSwiftType>(error: NSErrorPointer, @noescape _ closure: () throws -> [T]) -> [T.ObjectiveCType]? {
|
||||
internal func bridge<T: CoreStoreSwiftType>(_ error: NSErrorPointer, @noescape _ closure: () throws -> [T]) -> [T.ObjectiveCType]? {
|
||||
|
||||
do {
|
||||
|
||||
let result = try closure()
|
||||
error.memory = nil
|
||||
error?.pointee = nil
|
||||
return result.map { $0.bridgeToObjectiveC }
|
||||
}
|
||||
catch let swiftError {
|
||||
|
||||
error.memory = swiftError.bridgeToObjectiveC
|
||||
error?.pointee = swiftError.bridgeToObjectiveC
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,40 +27,40 @@ import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
||||
|
||||
// MARK: - NSFetchedResultsController
|
||||
|
||||
public extension NSFetchedResultsController {
|
||||
|
||||
/**
|
||||
Utility for creating an `NSFetchedResultsController` from a `CSDataStack`. This is useful when an `NSFetchedResultsController` is preferred over the overhead of `CSListMonitor`s abstractio
|
||||
|
||||
- parameter dataStack: the `CSDataStack` to observe objects from
|
||||
- parameter fetchRequest: the `NSFetchRequest` instance to use with the `NSFetchedResultsController`
|
||||
- parameter from: an optional `CSFrom` clause indicating the entity type. If not specified, the `fetchRequest` argument's `entity` property should already be set.
|
||||
- parameter sectionBy: a `CSSectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
@objc
|
||||
public static func cs_createForStack(dataStack: CSDataStack, fetchRequest: NSFetchRequest, from: CSFrom?, sectionBy: CSSectionBy?, fetchClauses: [CSFetchClause]) -> NSFetchedResultsController {
|
||||
|
||||
return CoreStoreFetchedResultsController(
|
||||
context: dataStack.bridgeToSwift.mainContext,
|
||||
fetchRequest: fetchRequest,
|
||||
from: from?.bridgeToSwift,
|
||||
sectionBy: sectionBy?.bridgeToSwift,
|
||||
applyFetchClauses: { fetchRequest in
|
||||
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
|
||||
CoreStore.assert(
|
||||
fetchRequest.sortDescriptors?.isEmpty == false,
|
||||
"An \(cs_typeName(NSFetchedResultsController)) requires a sort information. Specify from a \(cs_typeName(CSOrderBy)) clause or any custom \(cs_typeName(CSFetchClause)) that provides a sort descriptor."
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
//#if os(iOS) || os(watchOS) || os(tvOS)
|
||||
//
|
||||
//// MARK: - NSFetchedResultsController
|
||||
//
|
||||
//public extension NSFetchedResultsController {
|
||||
//
|
||||
// /**
|
||||
// Utility for creating an `NSFetchedResultsController` from a `CSDataStack`. This is useful when an `NSFetchedResultsController` is preferred over the overhead of `CSListMonitor`s abstractio
|
||||
//
|
||||
// - parameter dataStack: the `CSDataStack` to observe objects from
|
||||
// - parameter fetchRequest: the `NSFetchRequest` instance to use with the `NSFetchedResultsController`
|
||||
// - parameter from: an optional `CSFrom` clause indicating the entity type. If not specified, the `fetchRequest` argument's `entity` property should already be set.
|
||||
// - parameter sectionBy: a `CSSectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
// - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
// */
|
||||
// @objc
|
||||
// public static func cs_createForStack(_ dataStack: CSDataStack, fetchRequest: NSFetchRequest<NSFetchRequestResult>, from: CSFrom?, sectionBy: CSSectionBy?, fetchClauses: [CSFetchClause]) -> NSFetchedResultsController {
|
||||
//
|
||||
// return CoreStoreFetchedResultsController(
|
||||
// context: dataStack.bridgeToSwift.mainContext,
|
||||
// fetchRequest: fetchRequest,
|
||||
// from: from?.bridgeToSwift,
|
||||
// sectionBy: sectionBy?.bridgeToSwift,
|
||||
// applyFetchClauses: { fetchRequest in
|
||||
//
|
||||
// fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
//
|
||||
// CoreStore.assert(
|
||||
// fetchRequest.sortDescriptors?.isEmpty == false,
|
||||
// "An \(cs_typeName(NSFetchedResultsController)) requires a sort information. Specify from a \(cs_typeName(CSOrderBy)) clause or any custom \(cs_typeName(CSFetchClause)) that provides a sort descriptor."
|
||||
// )
|
||||
// }
|
||||
// )
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//#endif
|
||||
|
||||
@@ -39,7 +39,7 @@ public extension NSManagedObject {
|
||||
*/
|
||||
@objc
|
||||
@warn_unused_result
|
||||
public func cs_accessValueForKVCKey(KVCKey: KeyPath) -> AnyObject? {
|
||||
public func cs_accessValueForKVCKey(_ KVCKey: KeyPath) -> AnyObject? {
|
||||
|
||||
return self.accessValueForKVCKey(KVCKey)
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public extension NSManagedObject {
|
||||
- parameter KVCKey: the KVC key
|
||||
*/
|
||||
@objc
|
||||
public func cs_setValue(value: AnyObject?, forKVCKey KVCKey: KeyPath) {
|
||||
public func cs_setValue(_ value: AnyObject?, forKVCKey KVCKey: KeyPath) {
|
||||
|
||||
self.setValue(value, forKVCKey: KVCKey)
|
||||
}
|
||||
|
||||
@@ -34,43 +34,43 @@ internal extension NSManagedObjectContext {
|
||||
// MARK: Internal
|
||||
|
||||
@nonobjc
|
||||
internal func fetchOne(from: CSFrom, _ fetchClauses: [CSFetchClause]) -> NSManagedObject? {
|
||||
internal func fetchOne(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> NSManagedObject? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest()
|
||||
let fetchRequest = CoreStoreFetchRequest<NSManagedObject>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
|
||||
fetchRequest.fetchLimit = 1
|
||||
fetchRequest.resultType = .ManagedObjectResultType
|
||||
fetchRequest.resultType = .managedObjectResultType
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
|
||||
guard storeFound else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.fetchOne(fetchRequest)
|
||||
return self.fetchOne(fetchRequest.dynamicCast())
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func fetchAll(from: CSFrom, _ fetchClauses: [CSFetchClause]) -> [NSManagedObject]? {
|
||||
internal func fetchAll<T: NSManagedObject>(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> [T]? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest()
|
||||
let fetchRequest = CoreStoreFetchRequest<T>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
|
||||
fetchRequest.fetchLimit = 0
|
||||
fetchRequest.resultType = .ManagedObjectResultType
|
||||
fetchRequest.resultType = .managedObjectResultType
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
|
||||
guard storeFound else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.fetchAll(fetchRequest)
|
||||
return self.fetchAll(fetchRequest.dynamicCast())
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func fetchCount(from: CSFrom, _ fetchClauses: [CSFetchClause]) -> Int? {
|
||||
internal func fetchCount(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> Int? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest()
|
||||
let fetchRequest = CoreStoreFetchRequest<NSManagedObject>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
|
||||
@@ -78,51 +78,51 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.fetchCount(fetchRequest)
|
||||
return self.fetchCount(fetchRequest.dynamicCast())
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func fetchObjectID(from: CSFrom, _ fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
||||
internal func fetchObjectID(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest()
|
||||
let fetchRequest = CoreStoreFetchRequest<NSManagedObjectID>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
|
||||
fetchRequest.fetchLimit = 1
|
||||
fetchRequest.resultType = .ManagedObjectIDResultType
|
||||
fetchRequest.resultType = .managedObjectIDResultType
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
|
||||
guard storeFound else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.fetchObjectID(fetchRequest)
|
||||
return self.fetchObjectID(fetchRequest.dynamicCast())
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func fetchObjectIDs(from: CSFrom, _ fetchClauses: [CSFetchClause]) -> [NSManagedObjectID]? {
|
||||
internal func fetchObjectIDs(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> [NSManagedObjectID]? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest()
|
||||
let fetchRequest = CoreStoreFetchRequest<NSManagedObjectID>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
|
||||
fetchRequest.fetchLimit = 0
|
||||
fetchRequest.resultType = .ManagedObjectIDResultType
|
||||
fetchRequest.resultType = .managedObjectIDResultType
|
||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
|
||||
guard storeFound else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.fetchObjectIDs(fetchRequest)
|
||||
return self.fetchObjectIDs(fetchRequest.dynamicCast())
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func deleteAll(from: CSFrom, _ deleteClauses: [CSDeleteClause]) -> Int? {
|
||||
internal func deleteAll(_ from: CSFrom, _ deleteClauses: [CSDeleteClause]) -> Int? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest()
|
||||
let fetchRequest = CoreStoreFetchRequest<NSManagedObject>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
|
||||
fetchRequest.fetchLimit = 0
|
||||
fetchRequest.resultType = .ManagedObjectResultType
|
||||
fetchRequest.resultType = .managedObjectResultType
|
||||
fetchRequest.returnsObjectsAsFaults = true
|
||||
fetchRequest.includesPropertyValues = false
|
||||
deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||
@@ -131,13 +131,13 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.deleteAll(fetchRequest)
|
||||
return self.deleteAll(fetchRequest.dynamicCast())
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func queryValue(from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
internal func queryValue(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> AnyObject? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest()
|
||||
let fetchRequest = CoreStoreFetchRequest<NSFetchRequestResult>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
|
||||
fetchRequest.fetchLimit = 0
|
||||
@@ -150,13 +150,13 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.queryValue(selectTerms, fetchRequest: fetchRequest)
|
||||
return self.queryValue(selectTerms, fetchRequest: fetchRequest.dynamicCast())
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func queryAttributes(from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
internal func queryAttributes(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
|
||||
|
||||
let fetchRequest = CoreStoreFetchRequest()
|
||||
let fetchRequest = CoreStoreFetchRequest<NSFetchRequestResult>()
|
||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||
|
||||
fetchRequest.fetchLimit = 0
|
||||
@@ -168,6 +168,6 @@ internal extension NSManagedObjectContext {
|
||||
|
||||
return nil
|
||||
}
|
||||
return self.queryAttributes(fetchRequest)
|
||||
return self.queryAttributes(fetchRequest.dynamicCast())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import Foundation
|
||||
|
||||
// MARK: - NSProgress
|
||||
|
||||
public extension NSProgress {
|
||||
public extension Progress {
|
||||
|
||||
/**
|
||||
Sets a closure that the `NSProgress` calls whenever its `fractionCompleted` changes. You can use this instead of setting up KVO.
|
||||
@@ -36,7 +36,7 @@ public extension NSProgress {
|
||||
- parameter closure: the closure to execute on progress change
|
||||
*/
|
||||
@objc
|
||||
public func cs_setProgressHandler(closure: ((progress: NSProgress) -> Void)?) {
|
||||
public func cs_setProgressHandler(_ closure: ((progress: Progress) -> Void)?) {
|
||||
|
||||
self.setProgressHandler(closure)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user