mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-27 11:46:58 +02:00
Add integer methods
This commit is contained in:
@@ -76,6 +76,15 @@ extension KeychainStore: KeyValueStore {
|
||||
try keychain.set(value, key: key)
|
||||
}
|
||||
|
||||
func set(_ value: Int?, forKey key: KeyValueStoreKey) throws {
|
||||
guard let value = value else {
|
||||
try removeObject(forKey: key)
|
||||
return
|
||||
}
|
||||
|
||||
try keychain.set(String(value), key: key)
|
||||
}
|
||||
|
||||
// getters
|
||||
func data(forKey key: KeyValueStoreKey) throws -> Data? {
|
||||
return try keychain.getData(key)
|
||||
@@ -89,6 +98,10 @@ extension KeychainStore: KeyValueStore {
|
||||
return try keychain.getBool(key)
|
||||
}
|
||||
|
||||
func integer(forKey key: KeyValueStoreKey) throws -> Int? {
|
||||
return try Int(keychain.getString(key) ?? "")
|
||||
}
|
||||
|
||||
// remove
|
||||
func removeObject(forKey key: KeyValueStoreKey) throws {
|
||||
try keychain.remove(key)
|
||||
|
||||
Reference in New Issue
Block a user