gpt4 book ai didi

ios - 钥匙串(keychain)集 - NoSuchAttribute - 为什么?

转载 作者:行者123 更新时间:2023-11-29 05:25:31 25 4
gpt4 key购买 nike

这是我的代码:

static void SetA(byte[] b)
{
var result = SecKeyChain.Add(new SecRecord(SecKind.Key) { Generic = "test", ValueData = NSData.FromArray(b) });
Debug.WriteLine(result);
}

结果是:

NoSuchAttribute

  • 是因为我正在调试并且当我发布它时它会起作用吗?
  • 是因为我需要向 info.plist 添加一些内容吗?
  • 是因为我需要在配置中指定一些内容吗个人资料?
  • 或者是因为我遗漏了代码中的某些步骤?
  • ...

这是我第一次尝试使用 KeyChain,因此请不要低估(如“忽略”)我可能犯的任何简单错误。

最佳答案

我遇到了完全相同的错误。我正在关注这里的官方样本 https://github.com/xamarin/ios-samples/tree/master/Keychain .

我调试了一下,发现错误NoSuchAttribute来自Generic属性。在 official Apple documentation kSecAttrGeneric属性列在“密码属性”下。所以我假设 xamarin 示例是正确的,因为它使用 SecKind.GenericPassword .

替换Generic通过Label或其他东西来识别您的钥匙串(keychain)记录。

使用您的代码

static void SetA(byte[] b)
{
var result = SecKeyChain.Add(new SecRecord(SecKind.Key) {
Label = "test",
ValueData = NSData.FromArray(b)
});
Debug.WriteLine(result);
}

关于ios - 钥匙串(keychain)集 - NoSuchAttribute - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58221460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com