diff --git a/CoreStore.podspec b/CoreStore.podspec
index 989b6f6..1201e31 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 = "2.0.0"
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..7e7479f 100644
--- a/CoreStore/Info.plist
+++ b/CoreStore/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.5.1
+ 2.0.0
CFBundleSignature
????
CFBundleVersion
diff --git a/CoreStore/Saving and Processing/AsynchronousDataTransaction.swift b/CoreStore/Saving and Processing/AsynchronousDataTransaction.swift
index 8a2e293..8863cff 100644
--- a/CoreStore/Saving and Processing/AsynchronousDataTransaction.swift
+++ b/CoreStore/Saving and Processing/AsynchronousDataTransaction.swift
@@ -192,7 +192,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
/**
Rolls back the transaction by resetting the `NSManagedObjectContext`. After calling this method, all `NSManagedObjects` fetched within the transaction will become invalid. This method should not be used after the `commit()` method was already called once.
*/
- @available(*, deprecated=1.3.4, message="Resetting the context is inherently unsafe. This method will be removed in the near future. Use `beginUnsafe()` to create transactions with `undo` support.")
+ @available(*, deprecated=1.3.4, obsoleted=2.0.0, message="Resetting the context is inherently unsafe. This method will be removed in the near future. Use `beginUnsafe()` to create transactions with `undo` support.")
public func rollback() {
CoreStore.assert(
diff --git a/CoreStore/Saving and Processing/CoreStore+Transaction.swift b/CoreStore/Saving and Processing/CoreStore+Transaction.swift
index 2023d46..873a264 100644
--- a/CoreStore/Saving and Processing/CoreStore+Transaction.swift
+++ b/CoreStore/Saving and Processing/CoreStore+Transaction.swift
@@ -71,7 +71,7 @@ public extension CoreStore {
self.defaultStack.refreshAllObjectsAsFaults()
}
- @available(*, deprecated=1.3.1, renamed="beginUnsafe")
+ @available(*, deprecated=1.3.1, obsoleted=2.0.0, renamed="beginUnsafe")
@warn_unused_result
public static func beginDetached() -> UnsafeDataTransaction {
diff --git a/CoreStore/Saving and Processing/DataStack+Transaction.swift b/CoreStore/Saving and Processing/DataStack+Transaction.swift
index 9277d8b..7f565be 100644
--- a/CoreStore/Saving and Processing/DataStack+Transaction.swift
+++ b/CoreStore/Saving and Processing/DataStack+Transaction.swift
@@ -93,7 +93,7 @@ public extension DataStack {
self.mainContext.refreshAllObjectsAsFaults()
}
- @available(*, deprecated=1.3.1, renamed="beginUnsafe")
+ @available(*, deprecated=1.3.1, obsoleted=2.0.0, renamed="beginUnsafe")
@warn_unused_result
public func beginDetached() -> UnsafeDataTransaction {
diff --git a/CoreStore/Saving and Processing/SynchronousDataTransaction.swift b/CoreStore/Saving and Processing/SynchronousDataTransaction.swift
index cb11bf3..bb6404e 100644
--- a/CoreStore/Saving and Processing/SynchronousDataTransaction.swift
+++ b/CoreStore/Saving and Processing/SynchronousDataTransaction.swift
@@ -182,7 +182,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
/**
Rolls back the transaction by resetting the `NSManagedObjectContext`. After calling this method, all `NSManagedObjects` fetched within the transaction will become invalid. This method should not be used after the `commit()` method was already called once.
*/
- @available(*, deprecated=1.3.4, message="Resetting the context is inherently unsafe. This method will be removed in the near future. Use `beginUnsafe()` to create transactions with `undo` support.")
+ @available(*, deprecated=1.3.4, obsoleted=2.0.0, message="Resetting the context is inherently unsafe. This method will be removed in the near future. Use `beginUnsafe()` to create transactions with `undo` support.")
public func rollback() {
CoreStore.assert(
diff --git a/CoreStore/Saving and Processing/UnsafeDataTransaction.swift b/CoreStore/Saving and Processing/UnsafeDataTransaction.swift
index 74aaafe..26224c7 100644
--- a/CoreStore/Saving and Processing/UnsafeDataTransaction.swift
+++ b/CoreStore/Saving and Processing/UnsafeDataTransaction.swift
@@ -30,7 +30,7 @@ import CoreData
#endif
-@available(*, deprecated=1.3.1, renamed="UnsafeDataTransaction")
+@available(*, deprecated=1.3.1, obsoleted=2.0.0, renamed="UnsafeDataTransaction")
public typealias DetachedDataTransaction = UnsafeDataTransaction
@@ -119,7 +119,7 @@ public final class UnsafeDataTransaction: BaseDataTransaction {
return self.context
}
- @available(*, deprecated=1.3.1, renamed="beginUnsafe")
+ @available(*, deprecated=1.3.1, obsoleted=2.0.0, renamed="beginUnsafe")
@warn_unused_result
public func beginDetached() -> UnsafeDataTransaction {
diff --git a/CoreStore/Setting Up/DataStack.swift b/CoreStore/Setting Up/DataStack.swift
index ad02822..b68f643 100644
--- a/CoreStore/Setting Up/DataStack.swift
+++ b/CoreStore/Setting Up/DataStack.swift
@@ -129,41 +129,28 @@ public final class DataStack {
- parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`.
- returns: the `NSPersistentStore` added to the stack.
*/
+ @available(*, deprecated=2.0.0, renamed="beginUnsafe")
public func addInMemoryStoreAndWait(configuration configuration: String? = nil) throws -> NSPersistentStore {
- let coordinator = self.coordinator;
-
- var store: NSPersistentStore?
- var storeError: NSError?
- coordinator.performBlockAndWait {
-
- do {
-
- store = try coordinator.addPersistentStoreWithType(
- NSInMemoryStoreType,
- configuration: configuration,
- URL: nil,
- options: nil
- )
- }
- catch {
-
- storeError = error as NSError
- }
- }
-
- if let store = store {
+ do {
+ let store = try self.coordinator.addPersistentStoreSynchronously(
+ NSInMemoryStoreType,
+ configuration: configuration,
+ URL: nil,
+ options: nil
+ )
self.updateMetadataForPersistentStore(store)
return store
}
-
- let error = storeError ?? NSError(coreStoreErrorCode: .UnknownError)
- CoreStore.handleError(
- error,
- "Failed to add in-memory \(typeName(NSPersistentStore)) to the stack."
- )
- throw error
+ catch {
+
+ CoreStore.handleError(
+ error as NSError,
+ "Failed to add in-memory \(typeName(NSPersistentStore)) to the stack."
+ )
+ throw error
+ }
}
/**
@@ -227,68 +214,50 @@ public final class DataStack {
attributes: nil
)
- var store: NSPersistentStore?
- var storeError: NSError?
let options = self.optionsForSQLiteStore()
- coordinator.performBlockAndWait {
+ do {
+
+ let store = try coordinator.addPersistentStoreSynchronously(
+ NSSQLiteStoreType,
+ configuration: configuration,
+ URL: fileURL,
+ options: options
+ )
+ self.updateMetadataForPersistentStore(store)
+ return store
+ }
+ catch let error as NSError where resetStoreOnModelMismatch && error.isCoreDataMigrationError {
+
+ fileManager.removeSQLiteStoreAtURL(fileURL)
do {
- store = try coordinator.addPersistentStoreWithType(
+ let store = try coordinator.addPersistentStoreSynchronously(
NSSQLiteStoreType,
configuration: configuration,
URL: fileURL,
options: options
)
+ self.updateMetadataForPersistentStore(store)
+ return store
}
catch {
- storeError = error as NSError
+ CoreStore.handleError(
+ error as NSError,
+ "Failed to add SQLite \(typeName(NSPersistentStore)) at \"\(fileURL)\"."
+ )
+ throw error
}
}
-
- if let store = store {
+ catch {
- self.updateMetadataForPersistentStore(store)
- return store
+ CoreStore.handleError(
+ error as NSError,
+ "Failed to add SQLite \(typeName(NSPersistentStore)) at \"\(fileURL)\"."
+ )
+ throw error
}
-
- if let error = storeError
- where (resetStoreOnModelMismatch && error.isCoreDataMigrationError) {
-
- fileManager.removeSQLiteStoreAtURL(fileURL)
-
- var store: NSPersistentStore?
- coordinator.performBlockAndWait {
-
- do {
-
- store = try coordinator.addPersistentStoreWithType(
- NSSQLiteStoreType,
- configuration: configuration,
- URL: fileURL,
- options: [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
- )
- }
- catch {
-
- storeError = error as NSError
- }
- }
-
- if let store = store {
-
- self.updateMetadataForPersistentStore(store)
- return store
- }
- }
-
- let error = storeError ?? NSError(coreStoreErrorCode: .UnknownError)
- CoreStore.handleError(
- error,
- "Failed to add SQLite \(typeName(NSPersistentStore)) at \"\(fileURL)\"."
- )
- throw error
}
@@ -399,9 +368,7 @@ public final class DataStack {
deinit {
- for store in self.coordinator.persistentStores {
-
- _ = try? self.coordinator.removePersistentStore(store)
- }
+ let coordinator = self.coordinator
+ coordinator.persistentStores.forEach { _ = try? coordinator.removePersistentStore($0) }
}
}