Reputation: 20138
I am writing some keychain code on iOS. When I try to insert an item in keychain I get error -50.
What does OSStatus error -50 mean?
Upvotes: 3
Views: 14943
Reputation: 1682
If you are adding a password to the keychain make sure you pass it as Data and not String, otherwise you will get an OSStatus error -50.
static func savePassword(password: Data, account: String) throws -> OSStatus {
let query = [
kSecClass as String: kSecClassGenericPassword as String,
kSecAttrAccount as String: account,
kSecValueData as String: password
] as [String: Any]
SecItemDelete(query as CFDictionary)
return SecItemAdd(query as CFDictionary, nil)
}
Upvotes: 9
Reputation: 4520
Error -50
is a errSecParam
, and means that at least one of the parameters you passed in a function was/are not valid.
This can be due to type differences, or perhaps an invalid value.
See this page on the Apple site to read the official documentation from Apple on errSecParam
.
Upvotes: 2
Reputation: 8071
It's errSecParam
, indicating one or more of your parameters is wrong.
Upvotes: 9