From 0c8731c610dc2d453a78dee884ee0e432ec06d83 Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Sat, 28 May 2016 22:34:14 +0900 Subject: [PATCH] improved flushing behavior --- CoreStore.podspec | 2 +- CoreStore/Info.plist | 2 +- .../Internal/CoreStoreFetchedResultsController.swift | 4 ---- .../Saving and Processing/UnsafeDataTransaction.swift | 8 ++++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/CoreStore.podspec b/CoreStore.podspec index cea7eb3..56d4a87 100644 --- a/CoreStore.podspec +++ b/CoreStore.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CoreStore" - s.version = "1.6.8" + s.version = "1.6.9" 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 e09a8cf..ccca192 100644 --- a/CoreStore/Info.plist +++ b/CoreStore/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.6.8 + 1.6.9 CFBundleSignature ???? CFBundleVersion diff --git a/CoreStore/Internal/CoreStoreFetchedResultsController.swift b/CoreStore/Internal/CoreStoreFetchedResultsController.swift index de712a1..1286713 100644 --- a/CoreStore/Internal/CoreStoreFetchedResultsController.swift +++ b/CoreStore/Internal/CoreStoreFetchedResultsController.swift @@ -48,10 +48,6 @@ internal final class CoreStoreFetchedResultsController: NSFe internal init(context: NSManagedObjectContext, fetchRequest: NSFetchRequest, from: From? = nil, sectionBy: SectionBy? = nil, fetchClauses: [FetchClause]) { - CoreStore.assert( - fetchClauses.filter { $0 is OrderBy }.count > 0, - "An \(typeName(NSFetchedResultsController)) requires an OrderBy clause." - ) from?.applyToFetchRequest(fetchRequest, context: context, applyAffectedStores: false) for clause in fetchClauses { diff --git a/CoreStore/Saving and Processing/UnsafeDataTransaction.swift b/CoreStore/Saving and Processing/UnsafeDataTransaction.swift index 008431c..def35e3 100644 --- a/CoreStore/Saving and Processing/UnsafeDataTransaction.swift +++ b/CoreStore/Saving and Processing/UnsafeDataTransaction.swift @@ -97,9 +97,9 @@ public final class UnsafeDataTransaction: BaseDataTransaction { - Important: Note that unlike `commit()`, `flush()` does not propagate/save updates to the `DataStack` and the persistent store. However, the flushed changes will be seen by children transactions created further from the current transaction (i.e. through `transaction.beginUnsafe()`) - throws: an error thrown from `closure`, or an error thrown by Core Data (usually validation errors or conflict errors) */ - public func flush() throws { + public func flush() { - try self.context.save() + self.context.processPendingChanges() } /** @@ -109,10 +109,10 @@ public final class UnsafeDataTransaction: BaseDataTransaction { - parameter closure: the closure where changes can be made prior to the flush - throws: an error thrown from `closure`, or an error thrown by Core Data (usually validation errors or conflict errors) */ - public func flush(@noescape closure: () throws -> Void) throws { + public func flush(@noescape closure: () throws -> Void) rethrows { try closure() - try self.context.save() + self.context.processPendingChanges() } /**