diff --git a/Sources/Migrating/CoreStore+Migration.swift b/Sources/Migrating/CoreStore+Migration.swift index 1136bd3..d637c21 100644 --- a/Sources/Migrating/CoreStore+Migration.swift +++ b/Sources/Migrating/CoreStore+Migration.swift @@ -127,15 +127,19 @@ public extension CoreStore { /** Asynchronously adds a `CloudStorage` to the `defaultStack`. Migrations are also initiated by default. ``` + guard let storage = ICloudStore( + ubiquitousContentName: "MyAppCloudData", + ubiquitousContentTransactionLogsSubdirectory: "logs/config1", + ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", + ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", + configuration: "Config1", + cloudStorageOptions: .RecreateLocalStoreOnModelMismatch + ) else { + // iCloud is not available on the device + return + } let migrationProgress = dataStack.addStorage( - ICloudStore( - ubiquitousContentName: "MyAppCloudData", - ubiquitousContentTransactionLogsSubdirectory: "logs/config1", - ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", - ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", - configuration: "Config1", - cloudStorageOptions: .AllowSynchronousLightweightMigration - ), + storage, completion: { result in switch result { case .Success(let storage): // ... diff --git a/Sources/Migrating/DataStack+Migration.swift b/Sources/Migrating/DataStack+Migration.swift index 70559e1..d8d50cb 100644 --- a/Sources/Migrating/DataStack+Migration.swift +++ b/Sources/Migrating/DataStack+Migration.swift @@ -295,15 +295,19 @@ public extension DataStack { /** Asynchronously adds a `CloudStorage` to the stack. Migrations are also initiated by default. ``` + guard let storage = ICloudStore( + ubiquitousContentName: "MyAppCloudData", + ubiquitousContentTransactionLogsSubdirectory: "logs/config1", + ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", + ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", + configuration: "Config1", + cloudStorageOptions: .RecreateLocalStoreOnModelMismatch + ) else { + // iCloud is not available on the device + return + } dataStack.addStorage( - ICloudStore( - ubiquitousContentName: "MyAppCloudData", - ubiquitousContentTransactionLogsSubdirectory: "logs/config1", - ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", - ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", - configuration: "Config1", - cloudStorageOptions: .AllowSynchronousLightweightMigration - ), + storage, completion: { result in switch result { case .Success(let storage): // ... diff --git a/Sources/ObjectiveC/CoreStoreBridge.swift b/Sources/ObjectiveC/CoreStoreBridge.swift index 907125e..bcc2aa6 100644 --- a/Sources/ObjectiveC/CoreStoreBridge.swift +++ b/Sources/ObjectiveC/CoreStoreBridge.swift @@ -1,5 +1,5 @@ // -// CoreStoreObjectiveCType.swift +// CoreStoreBridge.swift // CoreStore // // Copyright © 2016 John Rommel Estropia diff --git a/Sources/Setup/CoreStore+Setup.swift b/Sources/Setup/CoreStore+Setup.swift index 11debcf..9201a96 100644 --- a/Sources/Setup/CoreStore+Setup.swift +++ b/Sources/Setup/CoreStore+Setup.swift @@ -134,16 +134,18 @@ public extension CoreStore { /** Adds a `CloudStorage` to the `defaultStack` and blocks until completion. ``` - try CoreStore.addStorageAndWait( - ICloudStore( - ubiquitousContentName: "MyAppCloudData", - ubiquitousContentTransactionLogsSubdirectory: "logs/config1", - ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", - ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", - configuration: "Config1", - cloudStorageOptions: .AllowSynchronousLightweightMigration - ) - ) + guard let storage = ICloudStore( + ubiquitousContentName: "MyAppCloudData", + ubiquitousContentTransactionLogsSubdirectory: "logs/config1", + ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", + ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", + configuration: "Config1", + cloudStorageOptions: .RecreateLocalStoreOnModelMismatch + ) else { + // iCloud is not available on the device + return + } + try CoreStore.addStorageAndWait(storage) ``` - parameter storage: the local storage diff --git a/Sources/Setup/DataStack.swift b/Sources/Setup/DataStack.swift index 2aa4949..bad563c 100644 --- a/Sources/Setup/DataStack.swift +++ b/Sources/Setup/DataStack.swift @@ -288,16 +288,18 @@ public final class DataStack { /** Adds a `CloudStorage` to the stack and blocks until completion. ``` - try dataStack.addStorageAndWait( - ICloudStore( - ubiquitousContentName: "MyAppCloudData", - ubiquitousContentTransactionLogsSubdirectory: "logs/config1", - ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", - ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", - configuration: "Config1", - cloudStorageOptions: .AllowSynchronousLightweightMigration - ) - ) + guard let storage = ICloudStore( + ubiquitousContentName: "MyAppCloudData", + ubiquitousContentTransactionLogsSubdirectory: "logs/config1", + ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", + ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", + configuration: "Config1", + cloudStorageOptions: .RecreateLocalStoreOnModelMismatch + ) else { + // iCloud is not available on the device + return + } + try dataStack.addStorageAndWait(storage) ``` - parameter storage: the local storage diff --git a/Sources/Setup/StorageInterfaces/ICloudStore.swift b/Sources/Setup/StorageInterfaces/ICloudStore.swift index 70223c8..06e3e8f 100644 --- a/Sources/Setup/StorageInterfaces/ICloudStore.swift +++ b/Sources/Setup/StorageInterfaces/ICloudStore.swift @@ -39,15 +39,19 @@ public class ICloudStore: CloudStorage { /** Initializes an iCloud store interface from the given ubiquitous store information. Returns `nil` if the container could not be located or if iCloud storage is unavailable for the current user or device ``` - try CoreStore.addStorage( - ICloudStore( - ubiquitousContentName: "MyAppCloudData", - ubiquitousContentTransactionLogsSubdirectory: "logs/config1", - ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", - ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", - configuration: "Config1", - cloudStorageOptions: .AllowSynchronousLightweightMigration - ) + guard let storage = ICloudStore( + ubiquitousContentName: "MyAppCloudData", + ubiquitousContentTransactionLogsSubdirectory: "logs/config1", + ubiquitousContainerID: "iCloud.com.mycompany.myapp.containername", + ubiquitousPeerToken: "9614d658014f4151a95d8048fb717cf0", + configuration: "Config1", + cloudStorageOptions: .RecreateLocalStoreOnModelMismatch + ) else { + // iCloud is not available on the device + return + } + CoreStore.addStorage( + storage, completion: { result in // ... } diff --git a/Sources/Setup/StorageInterfaces/SQLiteStore.swift b/Sources/Setup/StorageInterfaces/SQLiteStore.swift index 9ca7498..ee50d73 100644 --- a/Sources/Setup/StorageInterfaces/SQLiteStore.swift +++ b/Sources/Setup/StorageInterfaces/SQLiteStore.swift @@ -40,7 +40,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore { - parameter fileURL: the local file URL for the target SQLite persistent store. Note that if you have multiple configurations, you will need to specify a different `fileURL` explicitly for each of them. - parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`, the "Default" configuration. Note that if you have multiple configurations, you will need to specify a different `fileURL` explicitly for each of them. - - parameter mappingModelBundles: a list of `NSBundle`s from which to search mapping models for migration. + - parameter mappingModelBundles: a list of `NSBundle`s from which to search mapping models (*.xcmappingmodel) for migration. - parameter localStorageOptions: When the `SQLiteStore` is passed to the `DataStack`'s `addStorage()` methods, tells the `DataStack` how to setup the persistent store. Defaults to `.None`. */ public init(fileURL: NSURL, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles(), localStorageOptions: LocalStorageOptions = nil) { @@ -57,7 +57,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore { - Warning: The default SQLite file location for the `LegacySQLiteStore` and `SQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use `LegacySQLiteStore` instead of `SQLiteStore`. - parameter fileName: the local filename for the SQLite persistent store in the "Application Support/" directory (or the "Caches/" directory on tvOS). Note that if you have multiple configurations, you will need to specify a different `fileName` explicitly for each of them. - parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`, the "Default" configuration. Note that if you have multiple configurations, you will need to specify a different `fileName` explicitly for each of them. - - parameter mappingModelBundles: a list of `NSBundle`s from which to search mapping models for migration + - parameter mappingModelBundles: a list of `NSBundle`s from which to search mapping models (*.xcmappingmodel) for migration - parameter localStorageOptions: When the `SQLiteStore` is passed to the `DataStack`'s `addStorage()` methods, tells the `DataStack` how to setup the persistent store. Defaults to `.None`. */ public init(fileName: String, configuration: String? = nil, mappingModelBundles: [NSBundle] = NSBundle.allBundles(), localStorageOptions: LocalStorageOptions = nil) { diff --git a/Sources/Setup/StorageInterfaces/StorageInterface.swift b/Sources/Setup/StorageInterfaces/StorageInterface.swift index b3d9b76..63f37b2 100644 --- a/Sources/Setup/StorageInterfaces/StorageInterface.swift +++ b/Sources/Setup/StorageInterfaces/StorageInterface.swift @@ -141,7 +141,7 @@ public protocol LocalStorage: StorageInterface { var fileURL: NSURL { get } /** - The `NSBundle`s from which to search mapping models for migrations + The `NSBundle`s from which to search mapping models (*.xcmappingmodel) for migrations */ var mappingModelBundles: [NSBundle] { get } diff --git a/Sources/Transactions/SynchronousDataTransaction.swift b/Sources/Transactions/SynchronousDataTransaction.swift index 2725f91..76b337f 100644 --- a/Sources/Transactions/SynchronousDataTransaction.swift +++ b/Sources/Transactions/SynchronousDataTransaction.swift @@ -234,7 +234,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { self.context.reset() } - @available(*, deprecated=1.5.2, renamed="commitAndWait") + @available(*, deprecated=1.5.2, obsoleted=2.0.0, renamed="commitAndWait") public func commit() { self.commitAndWait()