DataStoreManager

@objcMembers
open class DataStoreManager : NSObject

An interface to the data store manager, where you store key-value pairs persistently across launches of your app.

  • Return a data store manager with the specified identifier.

    Initialize a new data store manager object immediately after memory for it has been allocated.

    Declaration

    Swift

    public required init(identifier: String)

    Parameters

    identifier

    A string identifying the data store manager object.

    Return Value

    An initialized object, or nil if an object could not be created for some reason that would not result in an exception.

  • Returns the data store manager framework short version string.

    Declaration

    Swift

    open var version: String? { get }
  • Returns the identifier of the data store manager.

    Declaration

    Swift

    open var identifier: String { get }
  • tag

    An integer that you can use to identify data store manager objects in your application.

    The default value is 0. You can set the value of this tag and use that value to identify the data store manager later.

    Declaration

    Swift

    open var tag: Int { get set }
  • The object that acts as the data source of the data store manager.

    The data source must adopt the DataStoreManagerDataSource protocol. The data source is not retained.

    Declaration

    Swift

    open weak var dataSource: DataStoreManagerDataSource? { get set }
  • The object that acts as the delegate of the data store manager.

    The delegate must adopt the DataStoreManagerDelegate protocol. The delegate is not retained.

    Declaration

    Swift

    open weak var delegate: DataStoreManagerDelegate? { get set }
  • An interface to the UserDefaults.

    Declaration

    Swift

    lazy var userDefaultsWorker: DataStoreManager.UserDefaultsWorker { get set }
  • An interface to the FileManager.

    Declaration

    Swift

    lazy var fileManagerWorker: DataStoreManager.FileManagerWorker { get set }
  • An interface to the NSCache.

    Declaration

    Swift

    lazy var cacheWorker: DataStoreManager.CacheWorker { get set }
  • An interface to the Security.

    Declaration

    Swift

    lazy var keychainWorker: DataStoreManager.KeychainWorker { get set }
  • An interface to the CoreData.

    Declaration

    Swift

    lazy var coreDataWorker: DataStoreManager.CoreDataWorker { get set }
  • An interface to the CloudKit.

    Declaration

    Swift

    @available(watchOSApplicationExtension 3.0, *)
    lazy var cloudKitWorker: DataStoreManager.CloudKitWorker { get set }
  • An interface to the NSUbiquitousKeyValueStore.

    Declaration

    Swift

    @available(watchOS, unavailable)
    lazy var ubiquitousCloudStoreWorker: DataStoreManager.UbiquitousCloudStoreWorker { get set }
  • Create the property of the receiver specified by a given key to a given object.

    Declaration

    Swift

    open func create(object: Any, forKey key: String, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    object

    The object for the property identified by key.

    key

    The name of one of the receiver’s properties.

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Create the property of the receiver specified by a given key to a given object.

    Declaration

    Swift

    open func create(object: Any, forKey key: String, forStorageType storageType: DataStoreStorageType, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    object

    The object for the property identified by key.

    key

    The key to identify the data store manager object.

    storageType

    A storage type constant.

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Returns the object associated with the specified key.

    Declaration

    Swift

    open func read<T>(forKey key: String, withObjectType objectType: T.Type, completionHandler: @escaping (_ object: Any?, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    key

    The key to identify the data store manager object.

    objectType

    The type of object for the property identified by key.

    completionHandler

    The block to execute with the associated object. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    object

    The object associated with the specified key, or nil if the key was not found.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Returns the object associated with the specified key.

    Declaration

    Swift

    open func read<T>(forKey key: String, withObjectType objectType: T.Type, forStorageType storageType: DataStoreStorageType, completionHandler: @escaping (_ object: Any?, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    key

    The key to identify the data store manager object.

    objectType

    The type of object for the property identified by key.

    storageType

    A storage type constant.

    completionHandler

    The block to execute with the associated object. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    object

    The object associated with the specified key, or nil if the key was not found.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Update the property of the receiver specified by a given key to a given object.

    Declaration

    Swift

    open func update(object: Any, forKey key: String, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    object

    The object for the property identified by key.

    key

    The name of one of the receiver’s properties.

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Update the property of the receiver specified by a given key to a given object.

    Declaration

    Swift

    open func update(object: Any, forKey key: String, forStorageType storageType: DataStoreStorageType, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    object

    The object for the property identified by key.

    key

    The key to identify the data store manager object.

    storageType

    A storage type constant.

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Removes the object of the specified default key.

    Declaration

    Swift

    open func delete<T>(forKey key: String, withObjectType objectType: T.Type, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    key

    The key to identify the data store manager object.

    objectType

    The type of object for the property identified by key.

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Removes the object of the specified default key.

    Declaration

    Swift

    open func delete<T>(forKey key: String, withObjectType objectType: T.Type, forStorageType storageType: DataStoreStorageType, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    key

    The key to identify the data store manager object.

    objectType

    The type of object for the property identified by key.

    storageType

    A storage type constant.

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Empties the data store manager for the given type.

    Declaration

    Swift

    open func deleteAll(completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Empties the data store manager for the given type.

    Declaration

    Swift

    open func deleteAll(forStorageType storageType: DataStoreStorageType, completionHandler: @escaping (_ isSuccessful: Bool, _ objectID: Any?, _ error: Error?) -> Void)

    Parameters

    storageType

    A storage type constant.

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    objectID

    The unique ID of the object. For CloudKit, the type is CKRecord.ID and it is the object that uniquely identifies a record in a database.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • Migrate the schema if the version differs.

    Call this function at the point where you app can migrate the schema. It will check first if the schema version is the same or not.If the schema needs to be migrated, it will call dataStoreManager(_:performMigrationFromOldVersion:forType:) delegate method.

    Declaration

    Swift

    open func migrateSchema(forStorageType storageType: DataStoreStorageType, completionHandler: @escaping (_ isSuccessful: Bool, _ error: Error?) -> Void)

    Parameters

    storageType

    A storage type constant.

    completionHandler

    The block to execute with the successful flag. This block is executed asynchronously on your app’s main thread. The block has no return value and takes the following parameter:

    isSuccessful

    true on successful; false if not.

    error

    An error object, or nil if it was completed successfully. Use the information in the error object to determine whether a problem has a workaround.

  • An interface to the NSCache.

    See more

    Declaration

    Swift

    internal class CacheWorker : NSDiscardableContent
  • An interface to the CloudKit.

    See more

    Declaration

    Swift

    @available(watchOSApplicationExtension 3.0, *)
    internal class CloudKitWorker
  • An interface to the NSUbiquitousKeyValueStore.

    See more

    Declaration

    Swift

    @available(watchOS, unavailable)
    internal class UbiquitousCloudStoreWorker