ICloudStore

@available(*, deprecated, message: "Please see the release notes and Core Data documentation.")
public final class ICloudStore : CloudStorage

A storage interface backed by an SQLite database managed by iCloud.

  • 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

    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
            // ...
        }
    )
    

    Declaration

    Swift

    public required init?(ubiquitousContentName: String, ubiquitousContentTransactionLogsSubdirectory: String, ubiquitousContainerID: String? = nil, ubiquitousPeerToken: String? = nil, configuration: ModelConfiguration = nil, cloudStorageOptions: CloudStorageOptions = nil)

    Parameters

    ubiquitousContentName

    the name of the store in iCloud. This is required and should not be empty, and should not contain periods (.).

    ubiquitousContentTransactionLogsSubdirectory

    a required relative path for the transaction logs

    ubiquitousContainerID

    a container if your app has multiple ubiquity container identifiers in its entitlements

    ubiquitousPeerToken

    a per-application salt to allow multiple apps on the same device to share a Core Data store integrated with iCloud

    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 ubiquitousContentName explicitly for each of them.

    cloudStorageOptions

    When the ICloudStore is passed to the DataStack‘s addStorage() methods, tells the DataStack how to setup the persistent store. Defaults to .None.

  • Registers an ICloudStoreObserver to start receive notifications from the ubiquitous store

    Declaration

    Swift

    public func addObserver<T>(_ observer: T) where T : ICloudStoreObserver

    Parameters

    observer

    the observer to start sending ubiquitous notifications to

  • Unregisters an ICloudStoreObserver to stop receiving notifications from the ubiquitous store

    Declaration

    Swift

    public func removeObserver(_ observer: ICloudStoreObserver)

    Parameters

    observer

    the observer to stop sending ubiquitous notifications to

  • The string identifier for the NSPersistentStore‘s type property. For SQLiteStores, this is always set to NSSQLiteStoreType.

    Declaration

    Swift

    public static let storeType: String
  • The configuration name in the model file

    Declaration

    Swift

    public let configuration: ModelConfiguration
  • The options dictionary for the NSPersistentStore. For SQLiteStores, this is always set to

    [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
    

    Declaration

    Swift

    public let storeOptions: [AnyHashable : Any]?
  • Do not call directly. Used by the DataStack internally.

    Declaration

    Swift

    public func cs_didAddToDataStack(_ dataStack: DataStack)
  • Do not call directly. Used by the DataStack internally.

    Declaration

    Swift

    public func cs_didRemoveFromDataStack(_ dataStack: DataStack)
  • Declaration

    Swift

    public var debugDescription: String { get }