KeyValueStoreProtocol
public protocol KeyValueStoreProtocol
KeyValueStore API.
-
Inserts a
SQLiteDatatypeBridgeablecompliant value into the mapping, replacing any existing value for the given key.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func put<T>(_ value: T?, forKey key: String) throws where T : SQLiteDatatypeBridgeableParameters
keya String
valuehas to be a
SQLiteDatatypeBridgeablecompliant object -
Inserts a
NSCodingcompliant value into the mapping, replacing any existing value for the given key.Note
This method serializes the value before it is inserted into the underlying store. Therefore, the values must be read with the
get<T: NSCoding>(_ key: String) throws -> T?in order to deserialize them properly. It is not possible to read values with specific get methods likegetString(key: String) throws -> String?.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func put<T>(_ value: T?, forKey key: String) throws where T : NSCodingParameters
keya String
valuehas to be a
NSCodingcompliant object -
Associates all specified values with their respective key. The effect of this call is equivalent to that of calling put(k, v) on this
SecureKeyValueStoreProtocolcompliant object once for each mapping from key k to value v in the specified map.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func putAll(_ keyValueDict: [String : NSCoding?]) throwsParameters
keyValueDictmappings to be stored
-
Returns the
NSCodingcompliant value to which the specified key is mapped, ornilif no mapping for this key exists.Note
This method deserializes the value when it is read from the underlying store. Therefore, the values must have been set with the
put(value: NSCoding?, forKey key: String) throwsmethod in order to be serialized properly. It is not possible to read values with this method that have been set with the specific put methods likeputString(value: String?, forKey key: String) throws.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func get<T>(_ key: String) throws -> T? where T : NSCodingReturn Value
the value as decoded value or
nil. -
Returns the
SQLiteDatatypeBridgeablecompliant value to which the specified key is mapped, ornilif no mapping for this key exists.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func get<T>(_ key: String) throws -> T? where T : SQLiteDatatypeBridgeableReturn Value
the value as decoded value or
nil. -
Returns the
Stringvalue associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getString(_ key: String) throws -> String?Parameters
keya String
Return Value
a String value or
nil -
Returns the
Int8value associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getInt8(_ key: String) throws -> Int8?Parameters
keya String
Return Value
an
Int8value ornil -
Returns the
Int16value associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getInt16(_ key: String) throws -> Int16?Parameters
keya String
Return Value
an
Int16value ornil -
Returns the
Int32value associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getInt32(_ key: String) throws -> Int32?Parameters
keya String
Return Value
an
Int32value ornil -
Returns the
Int64value associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getInt64(_ key: String) throws -> Int64?Parameters
keya String
Return Value
an
Int64value ornil -
Returns the
Intvalue associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getInt(_ key: String) throws -> Int?Parameters
keya String
Return Value
an
Intvalue ornil -
Returns the
UInt8value associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getUInt8(_ key: String) throws -> UInt8?Parameters
keya String
Return Value
an
UInt8value ornil -
Returns the UInt16 value associated with the given key, or
nilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getUInt16(_ key: String) throws -> UInt16?Parameters
keya String
Return Value
an
UInt16value ornil -
Returns the
UInt32value associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getUInt32(_ key: String) throws -> UInt32?Parameters
keya String
Return Value
an
UInt32value ornil -
Returns the
UInt64value associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getUInt64(_ key: String) throws -> UInt64?Parameters
keya String
Return Value
an
UInt64value ornil -
Returns the
UIntvalue associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getUInt(_ key: String) throws -> UInt?Parameters
keya String
Return Value
an
Intvalue ornil -
Returns the
Floatvalue associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getFloat(_ key: String) throws -> Float?Parameters
keya String
Return Value
a
Floatvalue ornil -
Returns the
Doublevalue associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getDouble(_ key: String) throws -> Double?Parameters
keya String
Return Value
a
Doublevalue ornil -
Returns the
Boolvalue associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Note
Conversions between different types of numbers may produce erroneous results. Such as putting an
Int64.maxfor a specific key and getting this value withtype: Int8. Conversions are handled in accordance to the behaviour ofNSNumber. Further information can be found at https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getBool(_ key: String) throws -> Bool?Parameters
keya String
Return Value
a
Boolvalue ornil -
Returns the
NSDatavalue associated with the given key, ornilif no mapping of the desired type exists for the given key or anilvalue is explicitly associated with the key.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func getData(_ key: String) throws -> Data?Parameters
keya String
Return Value
a
NSDatavalue ornil
-
Returns the
SQLiteDatatypeBridgeablecompliant value associated with the given key, ordefaultValueif no mapping of the desired type exists for the given key or if anilvalue is explicitly associated with the given key.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func get<T>(_ key: String, defaultValue: T?) throws -> T? where T : SQLiteDatatypeBridgeableParameters
keya String.
defaultValuereturned if key does not exist or if a
nilvalue is associated with the given key.Return Value
the decoded value associated with the given key, or
defaultValueif no valid object is currently mapped to that key. -
Returns the
NSCodingcompliant value associated with the given key, ordefaultValueif no mapping of the desired type exists for the given key or if anilvalue is explicitly associated with the given key.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.TypeConversionFailedif the value could not be decoded to the desired return type.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func get<T>(_ key: String, defaultValue: T?) throws -> T? where T : NSCodingParameters
keya String.
defaultValuereturned if key does not exist or if a
nilvalue is associated with the given key.Return Value
the decoded value associated with the given key, or
defaultValueif no valid object is currently mapped to that key.
-
Returns a Set containing the Strings used as keys in this
SecureKeyValueStore.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func keys() throws -> Set<String>Return Value
a
Setof keys. -
Returns whether the given key is contained in the mapping of this
SecureKeyValueStore.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func hasKey(_ key: String) throws -> BoolParameters
keya String.
Return Value
trueif the key is part of the mapping,falseotherwise
-
Returns the number of mappings contained in this
SecureKeyValueStoreProtocolcompliant object.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func count() throws -> IntReturn Value
the number of mappings as an Int.
-
Returns whether the mapping of this
SecureKeyValueStoreProtocolcompliant object is empty.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func isEmpty() throws -> BoolReturn Value
trueif the mapping of this SecureKeyValueStore is empty,falseotherwise.
-
Removes the entry with the given key from the mapping of this
SecureKeyValueStoreProtocolcompliant object.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
@discardableResult func remove(_ key: String) throws -> BoolParameters
keya String.
Return Value
trueif the key entry was successfully removed,falseif no mapping for the key exists. -
Removes all elements from the mapping of this
SecureKeyValueStoreProtocolcompliant object.Throws
SecureStorageError.Closedif theSecureKeyValueStoreProtocolcompliant object is locked with its encryption key.Throws
SecureStorageError.BackingStoreErrorif an error occured on the underlying store. Code corresponds to sqlite3 error codes (https://www.sqlite.org/c3ref/c_abort.html).Declaration
Swift
func removeAll() throws