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.
-
init(ubiquitousContentName:ubiquitousContentTransactionLogsSubdirectory:ubiquitousContainerID:ubiquitousPeerToken:configuration:cloudStorageOptions:)
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 deviceguard 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
, theDefault
configuration. Note that if you have multiple configurations, you will need to specify a differentubiquitousContentName
explicitly for each of them.cloudStorageOptions
-
Registers an
ICloudStoreObserver
to start receive notifications from the ubiquitous storeDeclaration
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 storeDeclaration
Swift
public func removeObserver(_ observer: ICloudStoreObserver)
Parameters
observer
the observer to stop sending ubiquitous notifications to
-
The string identifier for the
NSPersistentStore
‘stype
property. ForSQLiteStore
s, this is always set toNSSQLiteStoreType
.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
. ForSQLiteStore
s, this is always set to[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
Declaration
Swift
public let storeOptions: [AnyHashable : Any]?
-
The
NSURL
that points to the ubiquity container fileDeclaration
Swift
public let cacheFileURL: URL
-
Options that tell the
DataStack
how to setup the persistent storeDeclaration
Swift
public var cloudStorageOptions: CloudStorageOptions
-
The options dictionary for the specified
CloudStorageOptions
Declaration
Swift
public func dictionary(forOptions options: CloudStorageOptions) -> [AnyHashable : Any]?
-
Called by the
DataStack
to perform actual deletion of the store file from disk. Do not call directly! ThesourceModel
argument is a hint for the existing store’s model version. ForSQLiteStore
, this converts the database’s WAL journaling mode to DELETE before deleting the file.Declaration
Swift
public func cs_eraseStorageAndWait(soureModel: NSManagedObjectModel) throws
-
Declaration
Swift
public var debugDescription: String { get }