diff --git a/CoreStore.xcodeproj/project.pbxproj b/CoreStore.xcodeproj/project.pbxproj index 0801a46..b49ea3b 100644 --- a/CoreStore.xcodeproj/project.pbxproj +++ b/CoreStore.xcodeproj/project.pbxproj @@ -1667,27 +1667,27 @@ TargetAttributes = { 2F03A52F19C5C6DA005002A5 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 2F03A53A19C5C6DA005002A5 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 82BA18881C4BBCBA00A0916E = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 82BA18911C4BBCBA00A0916E = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; B52DD1731BE1F8CC00949AFE = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; B52DD17C1BE1F8CC00949AFE = { CreatedOnToolsVersion = 7.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; B563216E1BD65082006C9394 = { CreatedOnToolsVersion = 7.0.1; @@ -2550,6 +2550,7 @@ PRODUCT_NAME = CoreStore; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -2602,6 +2603,7 @@ PRODUCT_NAME = CoreStore; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; @@ -2625,7 +2627,8 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -2643,7 +2646,8 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -2663,7 +2667,8 @@ SDKROOT = iphoneos; SWIFT_OBJC_BRIDGING_HEADER = "CoreStoreTests/CoreStoreTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -2678,7 +2683,8 @@ PRODUCT_NAME = CoreStoreTests; SDKROOT = iphoneos; SWIFT_OBJC_BRIDGING_HEADER = "CoreStoreTests/CoreStoreTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -2698,7 +2704,8 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Debug; @@ -2719,7 +2726,8 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Release; @@ -2737,7 +2745,8 @@ SDKROOT = appletvos; SWIFT_OBJC_BRIDGING_HEADER = "CoreStoreTests/CoreStoreTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Debug; @@ -2755,7 +2764,8 @@ PRODUCT_NAME = CoreStoreTests; SDKROOT = appletvos; SWIFT_OBJC_BRIDGING_HEADER = "CoreStoreTests/CoreStoreTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Release; @@ -2779,7 +2789,8 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -2803,7 +2814,8 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -2823,7 +2835,8 @@ SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "CoreStoreTests/CoreStoreTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -2843,7 +2856,8 @@ PRODUCT_NAME = CoreStoreTests; SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "CoreStoreTests/CoreStoreTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -2864,6 +2878,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; }; @@ -2887,6 +2902,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; }; diff --git a/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj b/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj index 3417a4c..c92f2aa 100644 --- a/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj +++ b/CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj @@ -270,7 +270,7 @@ TargetAttributes = { B54AAD481AF4D26E00848AE0 = { CreatedOnToolsVersion = 6.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; }; }; @@ -407,6 +407,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; }; name = Debug; }; @@ -445,6 +446,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; VALIDATE_PRODUCT = YES; }; name = Release; @@ -458,7 +460,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.johnestropia.corestore.demo; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -472,7 +475,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.johnestropia.corestore.demo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift b/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift index 292cae1..c4329f2 100644 --- a/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/MIgrations Demo/MigrationsDemoViewController.swift @@ -109,7 +109,7 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD let dna = (self.listMonitor?[indexPath] as? OrganismProtocol)?.dna.description ?? "" cell.dnaLabel?.text = "DNA: \(dna)" - cell.mutateButtonHandler = { [weak self] _ -> Void in + cell.mutateButtonHandler = { [weak self] () -> Void in guard let `self` = self, let dataStack = self.dataStack, @@ -361,9 +361,10 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD self.segmentedControl?.selectedSegmentIndex = self.models .index( - where: { (_, _, schemaHistory) -> Bool in + where: { (arg) -> Bool in - schemaHistory.currentModelVersion == model.schemaHistory.currentModelVersion + let (_, _, schemaHistory) = arg + return schemaHistory.currentModelVersion == model.schemaHistory.currentModelVersion } )! diff --git a/CoreStoreTests/DynamicModelTests.swift b/CoreStoreTests/DynamicModelTests.swift index b63c708..10a1c99 100644 --- a/CoreStoreTests/DynamicModelTests.swift +++ b/CoreStoreTests/DynamicModelTests.swift @@ -137,7 +137,7 @@ class DynamicModelTests: BaseTestDataTestCase { XCTAssertEqual(dog.master.value, person) XCTAssertEqual(dog.master.value?.pets.value.first, dog) }, - success: { + success: { _ in updateDone.fulfill() }, @@ -171,7 +171,7 @@ class DynamicModelTests: BaseTestDataTestCase { let p3 = Dog.where({ $0.age == 10 }) XCTAssertEqual(p3.predicate, NSPredicate(format: "%K == %d", "age", 10)) }, - success: { + success: { _ in fetchDone.fulfill() }, diff --git a/CoreStoreTests/FetchTests.swift b/CoreStoreTests/FetchTests.swift index 92c1b5e..a700184 100644 --- a/CoreStoreTests/FetchTests.swift +++ b/CoreStoreTests/FetchTests.swift @@ -115,7 +115,7 @@ final class FetchTests: BaseTestDataTestCase { try transaction.cancel() }, - success: { + success: { _ in XCTFail() }, @@ -246,7 +246,7 @@ final class FetchTests: BaseTestDataTestCase { } try transaction.cancel() }, - success: { + success: { _ in XCTFail() }, diff --git a/CoreStoreTests/ImportTests.swift b/CoreStoreTests/ImportTests.swift index b248a10..e328891 100644 --- a/CoreStoreTests/ImportTests.swift +++ b/CoreStoreTests/ImportTests.swift @@ -565,7 +565,9 @@ class ImportTests: BaseTestDataTestCase { XCTAssertEqual(objects.count, 2) zip(objects, sourceArray) - .forEach { object, dictionary in + .forEach { + + let (object, dictionary) = $0 XCTAssertEqual(object.testEntityID, dictionary[(#keyPath(TestEntity1.testEntityID))] as? NSNumber) XCTAssertEqual(object.testBoolean, dictionary[(#keyPath(TestEntity1.testBoolean))] as? NSNumber) XCTAssertEqual(object.testNumber, dictionary[(#keyPath(TestEntity1.testNumber))] as? NSNumber) diff --git a/CoreStoreTests/ListObserverTests.swift b/CoreStoreTests/ListObserverTests.swift index 7e40beb..5e81c23 100644 --- a/CoreStoreTests/ListObserverTests.swift +++ b/CoreStoreTests/ListObserverTests.swift @@ -54,7 +54,7 @@ class ListObserverTests: BaseTestDataTestCase { var events = 0 let willChangeExpectation = self.expectation( - forNotification: "listMonitorWillChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorWillChange:"), object: observer, handler: { (note) -> Bool in @@ -68,7 +68,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didInsertSectionExpectation = self.expectation( - forNotification: "listMonitor:didInsertSection:toSectionIndex:", + forNotification: NSNotification.Name(rawValue: "listMonitor:didInsertSection:toSectionIndex:"), object: observer, handler: { (note) -> Bool in @@ -88,7 +88,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didInsertObjectExpectation = self.expectation( - forNotification: "listMonitor:didInsertObject:toIndexPath:", + forNotification: NSNotification.Name(rawValue: "listMonitor:didInsertObject:toIndexPath:"), object: observer, handler: { (note) -> Bool in @@ -120,7 +120,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didChangeExpectation = self.expectation( - forNotification: "listMonitorDidChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorDidChange:"), object: observer, handler: { (note) -> Bool in @@ -185,7 +185,7 @@ class ListObserverTests: BaseTestDataTestCase { var events = 0 let willChangeExpectation = self.expectation( - forNotification: "listMonitorWillChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorWillChange:"), object: observer, handler: { (note) -> Bool in @@ -200,7 +200,7 @@ class ListObserverTests: BaseTestDataTestCase { ) let didUpdateObjectExpectation = self.expectation( - forNotification: "listMonitor:didUpdateObject:atIndexPath:", + forNotification: NSNotification.Name(rawValue: "listMonitor:didUpdateObject:atIndexPath:"), object: observer, handler: { (note) -> Bool in @@ -251,7 +251,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didChangeExpectation = self.expectation( - forNotification: "listMonitorDidChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorDidChange:"), object: observer, handler: { (note) -> Bool in @@ -330,7 +330,7 @@ class ListObserverTests: BaseTestDataTestCase { var events = 0 let willChangeExpectation = self.expectation( - forNotification: "listMonitorWillChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorWillChange:"), object: observer, handler: { (note) -> Bool in @@ -344,7 +344,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didMoveObjectExpectation = self.expectation( - forNotification: "listMonitor:didMoveObject:fromIndexPath:toIndexPath:", + forNotification: NSNotification.Name(rawValue: "listMonitor:didMoveObject:fromIndexPath:toIndexPath:"), object: observer, handler: { (note) -> Bool in @@ -377,7 +377,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didChangeExpectation = self.expectation( - forNotification: "listMonitorDidChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorDidChange:"), object: observer, handler: { (note) -> Bool in @@ -438,7 +438,7 @@ class ListObserverTests: BaseTestDataTestCase { var events = 0 let willChangeExpectation = self.expectation( - forNotification: "listMonitorWillChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorWillChange:"), object: observer, handler: { (note) -> Bool in @@ -452,7 +452,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didUpdateObjectExpectation = self.expectation( - forNotification: "listMonitor:didDeleteObject:fromIndexPath:", + forNotification: NSNotification.Name(rawValue: "listMonitor:didDeleteObject:fromIndexPath:"), object: observer, handler: { (note) -> Bool in @@ -481,7 +481,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didDeleteSectionExpectation = self.expectation( - forNotification: "listMonitor:didDeleteSection:fromSectionIndex:", + forNotification: NSNotification.Name(rawValue: "listMonitor:didDeleteSection:fromSectionIndex:"), object: observer, handler: { (note) -> Bool in @@ -509,7 +509,7 @@ class ListObserverTests: BaseTestDataTestCase { } ) let didChangeExpectation = self.expectation( - forNotification: "listMonitorDidChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorDidChange:"), object: observer, handler: { (note) -> Bool in diff --git a/CoreStoreTests/ObjectObserverTests.swift b/CoreStoreTests/ObjectObserverTests.swift index bc62132..c23ace9 100644 --- a/CoreStoreTests/ObjectObserverTests.swift +++ b/CoreStoreTests/ObjectObserverTests.swift @@ -58,7 +58,7 @@ class ObjectObserverTests: BaseTestDataTestCase { var events = 0 let willUpdateExpectation = self.expectation( - forNotification: "objectMonitor:willUpdateObject:", + forNotification: NSNotification.Name(rawValue: "objectMonitor:willUpdateObject:"), object: observer, handler: { (note) -> Bool in @@ -75,7 +75,7 @@ class ObjectObserverTests: BaseTestDataTestCase { } ) let didUpdateExpectation = self.expectation( - forNotification: "objectMonitor:didUpdateObject:changedPersistentKeys:", + forNotification: NSNotification.Name(rawValue: "objectMonitor:didUpdateObject:changedPersistentKeys:"), object: observer, handler: { (note) -> Bool in @@ -155,7 +155,7 @@ class ObjectObserverTests: BaseTestDataTestCase { var events = 0 let didDeleteExpectation = self.expectation( - forNotification: "objectMonitor:didDeleteObject:", + forNotification: NSNotification.Name(rawValue: "objectMonitor:didDeleteObject:"), object: observer, handler: { (note) -> Bool in diff --git a/CoreStoreTests/TransactionTests.swift b/CoreStoreTests/TransactionTests.swift index 06252cc..36347b3 100644 --- a/CoreStoreTests/TransactionTests.swift +++ b/CoreStoreTests/TransactionTests.swift @@ -404,7 +404,7 @@ final class TransactionTests: BaseTestCase { var events = 0 let willChangeExpectation = self.expectation( - forNotification: "listMonitorWillChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorWillChange:"), object: observer, handler: { (note) -> Bool in @@ -418,7 +418,7 @@ final class TransactionTests: BaseTestCase { } ) let didInsertObjectExpectation = self.expectation( - forNotification: "listMonitor:didInsertObject:toIndexPath:", + forNotification: NSNotification.Name(rawValue: "listMonitor:didInsertObject:toIndexPath:"), object: observer, handler: { (note) -> Bool in @@ -448,7 +448,7 @@ final class TransactionTests: BaseTestCase { } ) let didChangeExpectation = self.expectation( - forNotification: "listMonitorDidChange:", + forNotification: NSNotification.Name(rawValue: "listMonitorDidChange:"), object: observer, handler: { (note) -> Bool in @@ -737,7 +737,7 @@ final class TransactionTests: BaseTestCase { createDiscardExpectation.fulfill() try transaction.cancel() }, - success: { + success: { _ in XCTFail() }, @@ -795,7 +795,7 @@ final class TransactionTests: BaseTestCase { try transaction.cancel() }, - success: { + success: { _ in XCTFail() }, @@ -828,7 +828,7 @@ final class TransactionTests: BaseTestCase { try transaction.cancel() }, - success: { + success: { _ in XCTFail() }, diff --git a/Sources/AsynchronousDataTransaction.swift b/Sources/AsynchronousDataTransaction.swift index d31380b..111404a 100644 --- a/Sources/AsynchronousDataTransaction.swift +++ b/Sources/AsynchronousDataTransaction.swift @@ -203,10 +203,10 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { self.isCommitted = true let group = DispatchGroup() group.enter() - self.context.saveAsynchronouslyWithCompletion { (result) -> Void in + self.context.saveAsynchronouslyWithCompletion { (hasChanges, error) -> Void in - completion(result.0, result.1) - self.result = result + completion(hasChanges, error) + self.result = (hasChanges, error) group.leave() } group.wait() @@ -226,12 +226,15 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { !self.isCommitted, "Attempted to commit a \(cs_typeName(self)) more than once." ) - self.autoCommit { (result) in + self.autoCommit { (hasChanges, error) in - switch result { + if let error = error { - case (let hasChanges, nil): completion(SaveResult(hasChanges: hasChanges)) - case (_, let error?): completion(SaveResult(error)) + completion(SaveResult(error)) + } + else { + + completion(SaveResult(hasChanges: hasChanges)) } } } diff --git a/Sources/CSAsynchronousDataTransaction.swift b/Sources/CSAsynchronousDataTransaction.swift index 797127c..34074c2 100644 --- a/Sources/CSAsynchronousDataTransaction.swift +++ b/Sources/CSAsynchronousDataTransaction.swift @@ -54,12 +54,15 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction, CoreSto !self.bridgeToSwift.isCommitted, "Attempted to commit a \(cs_typeName(self)) more than once." ) - self.bridgeToSwift.autoCommit { (result) in + self.bridgeToSwift.autoCommit { (_, error) in - switch result { + if let error = error { - case (_, nil): success?() - case (_, let error?): failure?(error.bridgeToObjectiveC) + failure?(error.bridgeToObjectiveC) + } + else { + + success?() } } } diff --git a/Sources/CSSelect.swift b/Sources/CSSelect.swift index d755766..e47d107 100644 --- a/Sources/CSSelect.swift +++ b/Sources/CSSelect.swift @@ -218,6 +218,7 @@ public final class CSSelect: NSObject { ``` - parameter numberTerm: the `CSSelectTerm` specifying the attribute/aggregate value to query */ + @objc public convenience init(numberTerm: CSSelectTerm) { self.init(Select(numberTerm.bridgeToSwift)) @@ -233,6 +234,7 @@ public final class CSSelect: NSObject { ``` - parameter decimalTerm: the `CSSelectTerm` specifying the attribute/aggregate value to query */ + @objc public convenience init(decimalTerm: CSSelectTerm) { self.init(Select(decimalTerm.bridgeToSwift)) @@ -248,6 +250,7 @@ public final class CSSelect: NSObject { ``` - parameter stringTerm: the `CSSelectTerm` specifying the attribute/aggregate value to query */ + @objc public convenience init(stringTerm: CSSelectTerm) { self.init(Select(stringTerm.bridgeToSwift)) @@ -263,6 +266,7 @@ public final class CSSelect: NSObject { ``` - parameter dateTerm: the `CSSelectTerm` specifying the attribute/aggregate value to query */ + @objc public convenience init(dateTerm: CSSelectTerm) { self.init(Select(dateTerm.bridgeToSwift)) @@ -278,6 +282,7 @@ public final class CSSelect: NSObject { ``` - parameter dataTerm: the `CSSelectTerm` specifying the attribute/aggregate value to query */ + @objc public convenience init(dataTerm: CSSelectTerm) { self.init(Select(dataTerm.bridgeToSwift)) @@ -292,6 +297,7 @@ public final class CSSelect: NSObject { // ... ``` */ + @objc public convenience init(objectIDTerm: ()) { self.init(Select(.objectID())) @@ -307,6 +313,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 */ + @objc public static func dictionaryForTerm(_ term: CSSelectTerm) -> CSSelect { return self.init(Select(term.bridgeToSwift)) @@ -325,6 +332,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 */ + @objc public static func dictionaryForTerms(_ terms: [CSSelectTerm]) -> CSSelect { return self.init(Select(terms.map { $0.bridgeToSwift })) diff --git a/Sources/CoreStoreSchema.swift b/Sources/CoreStoreSchema.swift index c041ecf..0f58b49 100644 --- a/Sources/CoreStoreSchema.swift +++ b/Sources/CoreStoreSchema.swift @@ -281,7 +281,7 @@ public final class CoreStoreSchema: DynamicSchema { case let attribute as AttributeProtocol: let description = NSAttributeDescription() description.name = attribute.keyPath - description.attributeType = type(of: attribute).attributeType + description.attributeType = Swift.type(of: attribute).attributeType description.isOptional = attribute.isOptional description.isIndexed = attribute.isIndexed description.defaultValue = attribute.defaultValue diff --git a/Sources/DataStack+Migration.swift b/Sources/DataStack+Migration.swift index d129ed0..df29437 100644 --- a/Sources/DataStack+Migration.swift +++ b/Sources/DataStack+Migration.swift @@ -647,8 +647,9 @@ public extension DataStack { let mappingProviders = storage.migrationMappingProviders do { - try withExtendedLifetime((sourceSchema.rawModel(), destinationSchema.rawModel())) { (sourceModel, destinationModel) in + try withExtendedLifetime((sourceSchema.rawModel(), destinationSchema.rawModel())) { + let (sourceModel, destinationModel) = $0 let mapping = try mappingProviders.findMapping( sourceSchema: sourceSchema, destinationSchema: destinationSchema, diff --git a/Sources/MigrationChain.swift b/Sources/MigrationChain.swift index 3f46dd8..c16e35b 100644 --- a/Sources/MigrationChain.swift +++ b/Sources/MigrationChain.swift @@ -117,8 +117,9 @@ public struct MigrationChain: ExpressibleByNilLiteral, ExpressibleByStringLitera var isValid = true var versionTree = [String: String]() - elements.forEach { (sourceVersion, destinationVersion) in + elements.forEach { + let (sourceVersion, destinationVersion) = $0 guard let _ = versionTree.updateValue(destinationVersion, forKey: sourceVersion) else { return @@ -130,8 +131,8 @@ public struct MigrationChain: ExpressibleByNilLiteral, ExpressibleByStringLitera } let leafVersions = Set( elements - .filter { versionTree[$1] == nil } - .map { $1 } + .filter { versionTree[$0.1] == nil } + .map { $0.1 } ) let isVersionAmbiguous = { (start: String) -> Bool in diff --git a/Sources/NSManagedObjectContext+Transaction.swift b/Sources/NSManagedObjectContext+Transaction.swift index f25f81d..7c76968 100644 --- a/Sources/NSManagedObjectContext+Transaction.swift +++ b/Sources/NSManagedObjectContext+Transaction.swift @@ -179,7 +179,7 @@ internal extension NSManagedObjectContext { } @nonobjc - internal func saveAsynchronouslyWithCompletion(_ completion: @escaping (_ hasChanges: Bool, _ error: CoreStoreError?) -> Void = { _ in }) { + internal func saveAsynchronouslyWithCompletion(_ completion: @escaping (_ hasChanges: Bool, _ error: CoreStoreError?) -> Void = { (_, _) in }) { self.perform { diff --git a/Sources/QueryableAttributeType.swift b/Sources/QueryableAttributeType.swift index a7ae995..f827a23 100644 --- a/Sources/QueryableAttributeType.swift +++ b/Sources/QueryableAttributeType.swift @@ -342,6 +342,7 @@ extension NSData: QueryableAttributeType { public typealias QueryableNativeType = NSData + @nonobjc public class var cs_rawAttributeType: NSAttributeType { return .binaryDataAttributeType @@ -372,6 +373,7 @@ extension NSDate: QueryableAttributeType { public typealias QueryableNativeType = NSDate + @nonobjc public class var cs_rawAttributeType: NSAttributeType { return .dateAttributeType @@ -413,6 +415,7 @@ extension NSManagedObjectID: QueryableAttributeType { public typealias QueryableNativeType = NSManagedObjectID + @nonobjc public class var cs_rawAttributeType: NSAttributeType { return .objectIDAttributeType @@ -443,6 +446,7 @@ extension NSNull: QueryableAttributeType { public typealias QueryableNativeType = NSNull + @nonobjc public class var cs_rawAttributeType: NSAttributeType { return .undefinedAttributeType @@ -473,6 +477,7 @@ extension NSNumber: QueryableAttributeType { public typealias QueryableNativeType = NSNumber + @objc public class var cs_rawAttributeType: NSAttributeType { return .integer64AttributeType @@ -503,6 +508,7 @@ extension NSString: QueryableAttributeType { public typealias QueryableNativeType = NSString + @nonobjc public class var cs_rawAttributeType: NSAttributeType { return .stringAttributeType @@ -533,6 +539,7 @@ extension NSURL: QueryableAttributeType { public typealias QueryableNativeType = NSString + @nonobjc public class var cs_rawAttributeType: NSAttributeType { return .stringAttributeType @@ -558,6 +565,7 @@ extension NSUUID: QueryableAttributeType { public typealias QueryableNativeType = NSString + @nonobjc public class var cs_rawAttributeType: NSAttributeType { return .stringAttributeType