gpt4 book ai didi

objective-c - 如何删除应用程序可访问的所有钥匙串(keychain)项目?

转载 作者:IT老高 更新时间:2023-10-28 11:41:27 27 4
gpt4 key购买 nike

我需要删除 iOS 上的杂散钥匙串(keychain)项(可能由旧版本的应用程序编写)。有没有简单的方法来实现这一点?

最佳答案

对所有类(class)都这样做

Objective-C :

NSArray *secItemClasses = @[(__bridge id)kSecClassGenericPassword,
(__bridge id)kSecClassInternetPassword,
(__bridge id)kSecClassCertificate,
(__bridge id)kSecClassKey,
(__bridge id)kSecClassIdentity];
for (id secItemClass in secItemClasses) {
NSDictionary *spec = @{(__bridge id)kSecClass: secItemClass};
SecItemDelete((__bridge CFDictionaryRef)spec);
}

swift :

let secItemClasses = [kSecClassGenericPassword, kSecClassInternetPassword, kSecClassCertificate, kSecClassKey, kSecClassIdentity]
for itemClass in secItemClasses {
let spec: NSDictionary = [kSecClass: itemClass]
SecItemDelete(spec)
}

关于objective-c - 如何删除应用程序可访问的所有钥匙串(keychain)项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14086085/

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