We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I would like to support saving integer to keychain. would this be ok? it seems working under iOS but i would like to be sure there nothing wrong:
extension KeychainSwift { func getInt(_ key: String) -> Int? { if let data = getData(key) { do { let number = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSNumber.self, from: data) return number?.intValue } catch { print("Unarchiving error: \(error)") return nil } } else { return nil } } @discardableResult func set(_ value: Int, forKey key: String) -> Bool { let number = NSNumber(value: value) do { let data = try NSKeyedArchiver.archivedData(withRootObject: number, requiringSecureCoding: true) return set(data, forKey: key) } catch { print("Archiving error: \(error)") return false } } }
And i would use it as:
let keychain = KeychainSwift() keychain.set(1234, forKey: "test") let testNumber = keychain.getInt("test")
The text was updated successfully, but these errors were encountered:
Sorry I don't want to add any new features to the library.
Sorry, something went wrong.
This would be really useful
@evgenyneu May I ask why you don't want to add new features?
No branches or pull requests
I would like to support saving integer to keychain.
would this be ok?
it seems working under iOS but i would like to be sure there nothing wrong:
And i would use it as:
The text was updated successfully, but these errors were encountered: