added obsolete annotations to previously deprecated methods

This commit is contained in:
John Rommel Estropia
2016-02-24 21:52:35 +09:00
parent 8f09f90294
commit f19a0d29eb
8 changed files with 54 additions and 87 deletions

View File

@@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "CoreStore" s.name = "CoreStore"
s.version = "1.5.1" s.version = "2.0.0"
s.license = "MIT" s.license = "MIT"
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift" s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
s.homepage = "https://github.com/JohnEstropia/CoreStore" s.homepage = "https://github.com/JohnEstropia/CoreStore"

View File

@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.5.1</string> <string>2.0.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>

View File

@@ -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. 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() { public func rollback() {
CoreStore.assert( CoreStore.assert(

View File

@@ -71,7 +71,7 @@ public extension CoreStore {
self.defaultStack.refreshAllObjectsAsFaults() self.defaultStack.refreshAllObjectsAsFaults()
} }
@available(*, deprecated=1.3.1, renamed="beginUnsafe") @available(*, deprecated=1.3.1, obsoleted=2.0.0, renamed="beginUnsafe")
@warn_unused_result @warn_unused_result
public static func beginDetached() -> UnsafeDataTransaction { public static func beginDetached() -> UnsafeDataTransaction {

View File

@@ -93,7 +93,7 @@ public extension DataStack {
self.mainContext.refreshAllObjectsAsFaults() self.mainContext.refreshAllObjectsAsFaults()
} }
@available(*, deprecated=1.3.1, renamed="beginUnsafe") @available(*, deprecated=1.3.1, obsoleted=2.0.0, renamed="beginUnsafe")
@warn_unused_result @warn_unused_result
public func beginDetached() -> UnsafeDataTransaction { public func beginDetached() -> UnsafeDataTransaction {

View File

@@ -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. 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() { public func rollback() {
CoreStore.assert( CoreStore.assert(

View File

@@ -30,7 +30,7 @@ import CoreData
#endif #endif
@available(*, deprecated=1.3.1, renamed="UnsafeDataTransaction") @available(*, deprecated=1.3.1, obsoleted=2.0.0, renamed="UnsafeDataTransaction")
public typealias DetachedDataTransaction = UnsafeDataTransaction public typealias DetachedDataTransaction = UnsafeDataTransaction
@@ -119,7 +119,7 @@ public final class UnsafeDataTransaction: BaseDataTransaction {
return self.context return self.context
} }
@available(*, deprecated=1.3.1, renamed="beginUnsafe") @available(*, deprecated=1.3.1, obsoleted=2.0.0, renamed="beginUnsafe")
@warn_unused_result @warn_unused_result
public func beginDetached() -> UnsafeDataTransaction { public func beginDetached() -> UnsafeDataTransaction {

View File

@@ -129,41 +129,28 @@ public final class DataStack {
- parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`. - parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`.
- returns: the `NSPersistentStore` added to the stack. - returns: the `NSPersistentStore` added to the stack.
*/ */
@available(*, deprecated=2.0.0, renamed="beginUnsafe")
public func addInMemoryStoreAndWait(configuration configuration: String? = nil) throws -> NSPersistentStore { public func addInMemoryStoreAndWait(configuration configuration: String? = nil) throws -> NSPersistentStore {
let coordinator = self.coordinator; do {
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 {
let store = try self.coordinator.addPersistentStoreSynchronously(
NSInMemoryStoreType,
configuration: configuration,
URL: nil,
options: nil
)
self.updateMetadataForPersistentStore(store) self.updateMetadataForPersistentStore(store)
return store return store
} }
catch {
let error = storeError ?? NSError(coreStoreErrorCode: .UnknownError)
CoreStore.handleError( CoreStore.handleError(
error, error as NSError,
"Failed to add in-memory \(typeName(NSPersistentStore)) to the stack." "Failed to add in-memory \(typeName(NSPersistentStore)) to the stack."
) )
throw error throw error
}
} }
/** /**
@@ -227,68 +214,50 @@ public final class DataStack {
attributes: nil attributes: nil
) )
var store: NSPersistentStore?
var storeError: NSError?
let options = self.optionsForSQLiteStore() 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 { do {
store = try coordinator.addPersistentStoreWithType( let store = try coordinator.addPersistentStoreSynchronously(
NSSQLiteStoreType, NSSQLiteStoreType,
configuration: configuration, configuration: configuration,
URL: fileURL, URL: fileURL,
options: options options: options
) )
self.updateMetadataForPersistentStore(store)
return store
} }
catch { catch {
storeError = error as NSError CoreStore.handleError(
error as NSError,
"Failed to add SQLite \(typeName(NSPersistentStore)) at \"\(fileURL)\"."
)
throw error
} }
} }
catch {
if let store = store {
self.updateMetadataForPersistentStore(store) CoreStore.handleError(
return store 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 { deinit {
for store in self.coordinator.persistentStores { let coordinator = self.coordinator
coordinator.persistentStores.forEach { _ = try? coordinator.removePersistentStore($0) }
_ = try? self.coordinator.removePersistentStore(store)
}
} }
} }