KeychainDataSource<T> is a Swift key-value storage that implements
DeleteDataSource storing values into the device Keychain. Type
T is required to be
// Swift let dataSource = KeychainDataSource<Double>(KeychainService()) dataSource.put(3.14159265359, forId: "pi") dataSource.get("pi") dataSource.delete("pi")
Note that the example above is using the extension methods of DataSoruce that encapsulate queries of type
KeychainService class is a wrapper on the iOS Keychain. For more details, read the class documentation.
All queries must adopt the
KeyQuery interface as the
KeychainDataSource<T> is based on a key-value pattern.
KeychainDataSource<T> has a generic type, the Keychain can only store
Data. However, the class has a built-in data conversion for any type
T that is
DataSourceMapper<In,Out> can be used to map any type
Among the typicial errors
CoreError.NotFound on GET methods, the
KeychainDataSource<T> can return the error
CoreError.OSStatusFailure in PUT and DELETE methods. This error is result of a failure in the manipulation of the Keychain. For more details, check the
OSStatus value of the error.