diff --git a/CoreStore.podspec b/CoreStore.podspec index 989b6f6..563275f 100644 --- a/CoreStore.podspec +++ b/CoreStore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CoreStore" - s.version = "1.5.1" + s.version = "1.5.2" s.license = "MIT" s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift" s.homepage = "https://github.com/JohnEstropia/CoreStore" diff --git a/CoreStore/Info.plist b/CoreStore/Info.plist index d18bd0a..c1add73 100644 --- a/CoreStore/Info.plist +++ b/CoreStore/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.5.1 + 1.5.2 CFBundleSignature ???? CFBundleVersion diff --git a/CoreStore/Saving and Processing/SynchronousDataTransaction.swift b/CoreStore/Saving and Processing/SynchronousDataTransaction.swift index cb11bf3..9519913 100644 --- a/CoreStore/Saving and Processing/SynchronousDataTransaction.swift +++ b/CoreStore/Saving and Processing/SynchronousDataTransaction.swift @@ -39,8 +39,10 @@ public final class SynchronousDataTransaction: BaseDataTransaction { /** Saves the transaction changes and waits for completion synchronously. This method should not be used after the `commit()` method was already called once. + + - returns: a `SaveResult` containing the success or failure information */ - public func commit() { + public func commitAndWait() -> SaveResult { CoreStore.assert( self.transactionQueue.isCurrentExecutionContext(), @@ -53,6 +55,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { self.isCommitted = true self.result = self.context.saveSynchronously() + return self.result } /** @@ -197,6 +200,12 @@ public final class SynchronousDataTransaction: BaseDataTransaction { self.context.reset() } + @available(*, deprecated=1.5.2, renamed="commitAndWait") + public func commit() { + + self.commitAndWait() + } + // MARK: Internal diff --git a/CoreStore/Saving and Processing/UnsafeDataTransaction.swift b/CoreStore/Saving and Processing/UnsafeDataTransaction.swift index 74aaafe..ae70fb0 100644 --- a/CoreStore/Saving and Processing/UnsafeDataTransaction.swift +++ b/CoreStore/Saving and Processing/UnsafeDataTransaction.swift @@ -55,6 +55,17 @@ public final class UnsafeDataTransaction: BaseDataTransaction { } } + /** + Saves the transaction changes and waits for completion synchronously. For a `UnsafeDataTransaction`, multiple commits are allowed, although it is the developer's responsibility to ensure a reasonable leeway to prevent blocking the main thread. + + - returns: a `SaveResult` containing the success or failure information + */ + public func commitAndWait() -> SaveResult { + + self.result = self.context.saveSynchronously() + return self.result + } + /** Rolls back the transaction. */