10 Commits
1.0.0 ... 1.1.1

Author SHA1 Message Date
Aleksey Zgurskiy
15284371dc Finish 1.1.1 2020-02-04 17:10:52 +02:00
Aleksey Zgurskiy
32ba85936c Update version 2020-02-04 17:10:39 +02:00
Aleksey Zgurskiy
0c902f0842 Merge branch 'fix/get-value' into develop 2020-02-04 17:09:53 +02:00
Aleksey Zgurskiy
7c4e5c205d Fix get value from keychain.swift 2020-02-04 17:09:46 +02:00
Aleksey Zgurskiy
40c4396b7e Finish 1.1.0 2020-02-03 10:39:19 +02:00
Aleksey Zgurskiy
a85afe2413 Finish 1.1.0 2020-02-03 10:39:07 +02:00
Aleksey Zgurskiy
b294163866 Update version 2020-02-03 10:38:50 +02:00
Aleksey Zgurskiy
2f4fa2e61a Merge branch 'feature/uuid' into develop 2020-02-03 10:38:20 +02:00
Aleksey Zgurskiy
51ee0ec8d7 Add uuid methods 2020-02-03 10:38:15 +02:00
Aleksey Zgurskiy
ebd2234deb Finish 1.0.0 2020-02-02 20:22:12 +02:00
2 changed files with 18 additions and 3 deletions

View File

@@ -302,7 +302,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.mr-noone.keychain-kit";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -327,7 +327,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.mr-noone.keychain-kit";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;

View File

@@ -26,6 +26,7 @@ public struct Keychain {
kSecClass : kSecClassGenericPassword,
kSecAttrAccount : key as AnyObject,
kSecMatchLimit : kSecMatchLimitOne,
kSecReturnAttributes : kCFBooleanTrue,
kSecReturnData : kCFBooleanTrue
]
@@ -46,7 +47,17 @@ public struct Keychain {
}
public func get(_ key: String) throws -> String {
return String(data: try get(key), encoding: .utf8)!
guard let value = String(data: try get(key), encoding: .utf8) else {
throw Error.unexpectedData
}
return value
}
public func get(_ key: String) throws -> UUID {
guard let value = UUID(uuidString: try get(key)) else {
throw Error.unexpectedData
}
return value
}
public func get<T>(_ key: String, decoder: JSONDecoder = JSONDecoder()) throws -> T where T: Decodable {
@@ -70,6 +81,10 @@ public struct Keychain {
try set(value.data(using: .utf8)!, for: key)
}
public func set(_ uuid: UUID, for key: String) throws {
try set(uuid.uuidString, for: key)
}
public func set<T>(_ value: T, for key: String, encoder: JSONEncoder = JSONEncoder()) throws where T: Encodable {
try set(encoder.encode(value), for: key)
}