IndexedDataStore
public final class IndexedDataStore
Persistent data store with data objects indexed by identifier.
-
The name of the data store.
Declaration
Swift
public let name: String -
Creates a data store with the given name.
Declaration
Swift
public init(name: String) throwsParameters
nameThe name of the data store.
-
Value type of the identifier.
Declaration
Swift
public typealias Identifier = String -
Loads data asynchonously from the persistent data store.
Declaration
Swift
public func loadData<T>(forIdentifier identifier: Identifier, dataTransformer: @escaping (Data) -> T?, completionHandler: @escaping (T?) -> Void)Parameters
identifierThe identifier of the data.
dataTransformerTransforms data to a specified type.
completionHandlerThe block to execute after the operation’s main task is completed.
-
Store data asynchronously in persistent data store.
Declaration
Swift
public func storeData(_ dataProvider: @escaping () -> Data?, identifier: Identifier = UUID().uuidString, completionHandler: @escaping (Result<Identifier, Error>) -> Void)Parameters
dataProviderThe block providing data. Runs on a background thread.
identifierThe identifier of the data.
completionHandlerThe block to execute after the operation’s main task is completed.
-
Removes data stored in the persistent data store.
Declaration
Swift
public func removeData(forIdentifier identifier: Identifier)Parameters
identifierThe identifier of the data.
-
Removes all the stored data objects.
Declaration
Swift
public func removeAll()
-
Loads image asynchonously from persistent data store.
Declaration
Swift
func loadImage(forIdentifier identifier: Identifier, completionHandler: @escaping (UIImage?) -> Void)Parameters
identifierThe identifier of the image.
completionHandlerThe block to execute after the operation’s main task is completed.
-
Store data asynchronously in persistent data store.
Declaration
Swift
func storeImage(_ image: UIImage, identifier: Identifier = UUID().uuidString, completionHandler: @escaping (Result<Identifier, Error>) -> Void)Parameters
imageUIImage to store.
identifierThe identifier of the image.
completionHandlerThe block to execute after the operation’s main task is completed.
View on GitHub
IndexedDataStore Class Reference