diff --git a/CoreStoreTests/BaseTests/BaseTestDataTestCase.swift b/CoreStoreTests/BaseTests/BaseTestDataTestCase.swift index 6963c64..ba86b1d 100644 --- a/CoreStoreTests/BaseTests/BaseTestDataTestCase.swift +++ b/CoreStoreTests/BaseTests/BaseTestDataTestCase.swift @@ -30,7 +30,7 @@ class BaseTestDataTestCase: BaseTestCase { @nonobjc func prepareTestDataForStack(_ stack: DataStack, configurations: [String?] = [nil]) { - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in for (configurationIndex, configuration) in configurations.enumerated() { diff --git a/CoreStoreTests/FetchTests.swift b/CoreStoreTests/FetchTests.swift index 45e6021..7e03514 100644 --- a/CoreStoreTests/FetchTests.swift +++ b/CoreStoreTests/FetchTests.swift @@ -73,7 +73,7 @@ final class FetchTests: BaseTestDataTestCase { let fetchExpectation = self.expectation(withDescription: "fetch") var existing1: TestEntity1? - _ = _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in existing1 = transaction.fetchExisting(object) XCTAssertNotNil(existing1) @@ -166,7 +166,7 @@ final class FetchTests: BaseTestDataTestCase { let fetchExpectation = self.expectation(withDescription: "fetch") var existing1 = [TestEntity1]() - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in existing1 = transaction.fetchExisting(objects) XCTAssertEqual( @@ -1724,7 +1724,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From() do { @@ -1768,7 +1768,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertNil(objectID) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil) do { @@ -1812,7 +1812,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertNil(objectID) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1") do { @@ -1863,7 +1863,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From() do { @@ -1907,7 +1907,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertNil(objectID) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil) do { @@ -1951,7 +1951,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertNil(objectID) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1") do { @@ -1995,7 +1995,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertNil(objectID) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config2") do { @@ -2046,7 +2046,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil, "Config1") do { @@ -2090,7 +2090,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertNil(objectID) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil, "Config2") do { @@ -2134,7 +2134,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertNil(objectID) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1", "Config2") do { @@ -2189,7 +2189,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From() do { @@ -2259,7 +2259,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(objectIDs?.count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil) do { @@ -2329,7 +2329,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(objectIDs?.count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1") do { @@ -2380,7 +2380,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From() do { @@ -2444,7 +2444,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(objectIDs?.count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil) do { @@ -2512,7 +2512,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(objectIDs?.count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1") do { @@ -2580,7 +2580,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(objectIDs?.count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config2") do { @@ -2629,7 +2629,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil, "Config1") do { @@ -2693,7 +2693,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(objectIDs?.count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil, "Config2") do { @@ -2761,7 +2761,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(objectIDs?.count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1", "Config2") do { @@ -2840,7 +2840,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From() do { @@ -2876,7 +2876,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil) do { @@ -2912,7 +2912,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1") do { @@ -2951,7 +2951,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From() do { @@ -2987,7 +2987,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil) do { @@ -3023,7 +3023,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1") do { @@ -3059,7 +3059,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config2") do { @@ -3098,7 +3098,7 @@ final class FetchTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack, configurations: configurations) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil, "Config1") do { @@ -3134,7 +3134,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From(nil, "Config2") do { @@ -3170,7 +3170,7 @@ final class FetchTests: BaseTestDataTestCase { XCTAssertEqual(count, 0) } } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let from = From("Config1", "Config2") do { diff --git a/CoreStoreTests/ImportTests.swift b/CoreStoreTests/ImportTests.swift index 7372551..1828de0 100644 --- a/CoreStoreTests/ImportTests.swift +++ b/CoreStoreTests/ImportTests.swift @@ -38,7 +38,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareStack { (stack) in - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { @@ -70,7 +70,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareStack { (stack) in - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let errorExpectation = self.expectation(withDescription: "error") do { @@ -119,7 +119,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareStack { (stack) in - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { @@ -178,7 +178,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareStack { (stack) in - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { @@ -232,7 +232,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareStack { (stack) in - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let errorExpectation = self.expectation(withDescription: "error") do { @@ -292,7 +292,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareStack { (stack) in - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { @@ -351,7 +351,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { @@ -421,7 +421,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { @@ -521,7 +521,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { @@ -600,7 +600,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { @@ -658,7 +658,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let errorExpectation = self.expectation(withDescription: "error") do { @@ -705,7 +705,7 @@ class ImportTests: BaseTestDataTestCase { self.checkExpectationsImmediately() transaction.context.reset() } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let errorExpectation = self.expectation(withDescription: "error") do { @@ -758,7 +758,7 @@ class ImportTests: BaseTestDataTestCase { self.checkExpectationsImmediately() transaction.context.reset() } - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let errorExpectation = self.expectation(withDescription: "error") do { @@ -820,7 +820,7 @@ class ImportTests: BaseTestDataTestCase { self.prepareTestDataForStack(stack) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in do { diff --git a/CoreStoreTests/TransactionTests.swift b/CoreStoreTests/TransactionTests.swift index 058788b..ffc1364 100644 --- a/CoreStoreTests/TransactionTests.swift +++ b/CoreStoreTests/TransactionTests.swift @@ -43,7 +43,7 @@ final class TransactionTests: BaseTestCase { do { let createExpectation = self.expectation(withDescription: "create") - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let object = transaction.create(Into()) object.testEntityID = NSNumber(value: 1) @@ -75,7 +75,7 @@ final class TransactionTests: BaseTestCase { do { let updateExpectation = self.expectation(withDescription: "update") - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in guard let object = transaction.fetchOne(From()) else { @@ -110,7 +110,7 @@ final class TransactionTests: BaseTestCase { do { let deleteExpectation = self.expectation(withDescription: "delete") - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let object = transaction.fetchOne(From()) transaction.delete(object) @@ -144,7 +144,7 @@ final class TransactionTests: BaseTestCase { do { let createExpectation = self.expectation(withDescription: "create") - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let object = transaction.create(Into("Config1")) object.testEntityID = NSNumber(value: 1) @@ -177,7 +177,7 @@ final class TransactionTests: BaseTestCase { do { let updateExpectation = self.expectation(withDescription: "update") - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in guard let object = transaction.fetchOne(From("Config1")) else { @@ -213,7 +213,7 @@ final class TransactionTests: BaseTestCase { do { let deleteExpectation = self.expectation(withDescription: "delete") - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let object = transaction.fetchOne(From("Config1")) transaction.delete(object) @@ -245,7 +245,7 @@ final class TransactionTests: BaseTestCase { let createDiscardExpectation = self.expectation(withDescription: "create-discard") let loggerExpectations = self.prepareLoggerExpectations([.logWarning]) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let object = transaction.create(Into()) object.testEntityID = NSNumber(value: 1) @@ -267,7 +267,7 @@ final class TransactionTests: BaseTestCase { do { let createExpectation = self.expectation(withDescription: "create") - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in let object = transaction.create(Into()) object.testEntityID = NSNumber(value: 1) @@ -290,7 +290,7 @@ final class TransactionTests: BaseTestCase { let updateDiscardExpectation = self.expectation(withDescription: "update-discard") let loggerExpectations = self.prepareLoggerExpectations([.logWarning]) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in guard let object = transaction.fetchOne(From()) else { @@ -319,7 +319,7 @@ final class TransactionTests: BaseTestCase { let deleteDiscardExpectation = self.expectation(withDescription: "delete-discard") let loggerExpectations = self.prepareLoggerExpectations([.logWarning]) - _ = stack.beginSynchronous { (transaction) in + stack.beginSynchronous { (transaction) in guard let object = transaction.fetchOne(From()) else { diff --git a/Sources/Internal/FetchedResultsControllerDelegate.swift b/Sources/Internal/FetchedResultsControllerDelegate.swift index 7e7fd95..ca6b34b 100644 --- a/Sources/Internal/FetchedResultsControllerDelegate.swift +++ b/Sources/Internal/FetchedResultsControllerDelegate.swift @@ -76,7 +76,7 @@ internal final class FetchedResultsControllerDelegate) { + dynamic func controllerWillChangeContent(_ controller: NSFetchedResultsController) { guard self.enabled else { diff --git a/Sources/ObjectiveC/CSAsynchronousDataTransaction.swift b/Sources/ObjectiveC/CSAsynchronousDataTransaction.swift index c213a86..70b06c3 100644 --- a/Sources/ObjectiveC/CSAsynchronousDataTransaction.swift +++ b/Sources/ObjectiveC/CSAsynchronousDataTransaction.swift @@ -58,6 +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 + @discardableResult public func beginSynchronous(_ closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? { return bridge { diff --git a/Sources/ObjectiveC/CSCoreStore+Transaction.swift b/Sources/ObjectiveC/CSCoreStore+Transaction.swift index b6c68f1..c793d54 100644 --- a/Sources/ObjectiveC/CSCoreStore+Transaction.swift +++ b/Sources/ObjectiveC/CSCoreStore+Transaction.swift @@ -51,6 +51,7 @@ public extension CSCoreStore { - returns: a `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ @objc + @discardableResult public static func beginSynchronous(_ closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? { return bridge { diff --git a/Sources/ObjectiveC/CSDataStack+Transaction.swift b/Sources/ObjectiveC/CSDataStack+Transaction.swift index ebdfca9..b4416b8 100644 --- a/Sources/ObjectiveC/CSDataStack+Transaction.swift +++ b/Sources/ObjectiveC/CSDataStack+Transaction.swift @@ -51,6 +51,7 @@ public extension CSDataStack { - returns: a `CSSaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ @objc + @discardableResult public func beginSynchronous(_ closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? { return bridge { diff --git a/Sources/ObjectiveC/CSSynchronousDataTransaction.swift b/Sources/ObjectiveC/CSSynchronousDataTransaction.swift index 774849d..767b25c 100644 --- a/Sources/ObjectiveC/CSSynchronousDataTransaction.swift +++ b/Sources/ObjectiveC/CSSynchronousDataTransaction.swift @@ -58,6 +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 + @discardableResult public func beginSynchronous(_ closure: (transaction: CSSynchronousDataTransaction) -> Void) -> CSSaveResult? { return bridge { diff --git a/Sources/Observing/ObjectMonitor.swift b/Sources/Observing/ObjectMonitor.swift index 0b7d9d1..01ba28d 100644 --- a/Sources/Observing/ObjectMonitor.swift +++ b/Sources/Observing/ObjectMonitor.swift @@ -367,8 +367,8 @@ extension ObjectMonitor: FetchedResultsControllerHandler { private extension Notification.Name { private static let objectMonitorWillChangeObject = Notification.Name(rawValue: "objectMonitorWillChangeObject") - private static let objectMonitorDidDeleteObject = Notification.Name(rawValue: "objectMonitorWillChangeObject") - private static let objectMonitorDidUpdateObject = Notification.Name(rawValue: "objectMonitorWillChangeObject") + private static let objectMonitorDidDeleteObject = Notification.Name(rawValue: "objectMonitorDidDeleteObject") + private static let objectMonitorDidUpdateObject = Notification.Name(rawValue: "objectMonitorDidUpdateObject") } #endif diff --git a/Sources/Transactions/AsynchronousDataTransaction.swift b/Sources/Transactions/AsynchronousDataTransaction.swift index a634030..5d8040b 100644 --- a/Sources/Transactions/AsynchronousDataTransaction.swift +++ b/Sources/Transactions/AsynchronousDataTransaction.swift @@ -71,6 +71,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { - 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`. - returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ + @discardableResult public func beginSynchronous(_ closure: (transaction: SynchronousDataTransaction) -> Void) -> SaveResult? { CoreStore.assert( diff --git a/Sources/Transactions/CoreStore+Transaction.swift b/Sources/Transactions/CoreStore+Transaction.swift index 1eef738..aaa1277 100644 --- a/Sources/Transactions/CoreStore+Transaction.swift +++ b/Sources/Transactions/CoreStore+Transaction.swift @@ -46,6 +46,7 @@ public extension CoreStore { - 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`. - returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ + @discardableResult public static func beginSynchronous(_ closure: (transaction: SynchronousDataTransaction) -> Void) -> SaveResult? { return self.defaultStack.beginSynchronous(closure) diff --git a/Sources/Transactions/DataStack+Transaction.swift b/Sources/Transactions/DataStack+Transaction.swift index c7c0789..db91ecc 100644 --- a/Sources/Transactions/DataStack+Transaction.swift +++ b/Sources/Transactions/DataStack+Transaction.swift @@ -53,6 +53,7 @@ public extension DataStack { - 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`. - returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ + @discardableResult public func beginSynchronous(_ closure: (transaction: SynchronousDataTransaction) -> Void) -> SaveResult? { return SynchronousDataTransaction( diff --git a/Sources/Transactions/SynchronousDataTransaction.swift b/Sources/Transactions/SynchronousDataTransaction.swift index 192fcda..6d6a272 100644 --- a/Sources/Transactions/SynchronousDataTransaction.swift +++ b/Sources/Transactions/SynchronousDataTransaction.swift @@ -66,6 +66,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { - 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`. - returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously */ + @discardableResult public func beginSynchronous(_ closure: (transaction: SynchronousDataTransaction) -> Void) -> SaveResult? { CoreStore.assert(