【问题标题】:What does OSStatus Error -50 mean?OSStatus 错误 -50 是什么意思?
【发布时间】:2014-11-03 16:04:10
【问题描述】:

我正在 iOS 上编写一些钥匙串代码。当我尝试在钥匙串中插入项目时,出现错误 -50。

OSStatus 错误 -50 是什么意思?

【问题讨论】:

标签: ios keychain


【解决方案1】:
【解决方案2】:

如果您要向钥匙串添加密码,请确保将其作为数据而不是字符串传递,否则您将收到 OSStatus 错误 -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)
}

【讨论】:

  • SecItemDelete(query as CFDictionary) 解决了我的问题的行,谢谢:)
【解决方案3】:

错误-50errSecParam,这意味着您在函数中传递的至少一个参数是/无效的。

这可能是由于类型差异,或者可能是无效值。 See this page on the Apple siteerrSecParam 上阅读 Apple 的官方文档。

【讨论】:

    猜你喜欢
    • 2019-11-26
    • 1970-01-01
    • 2015-03-04
    • 2012-11-26
    • 2018-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-08
    相关资源
    最近更新 更多