iOS(おそらく古いバージョンのアプリで作成されたもの)に、削除する必要のある迷子のキーチェーンアイテムがあります。これを達成する簡単な方法はありますか?
30377 次
7 に答える
84
全てのクラスで行う
目的 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);
}
迅速:
let secItemClasses = [kSecClassGenericPassword, kSecClassInternetPassword, kSecClassCertificate, kSecClassKey, kSecClassIdentity]
for itemClass in secItemClasses {
let spec: NSDictionary = [kSecClass: itemClass]
SecItemDelete(spec)
}
于 2012-12-29T22:02:21.350 に答える
15
アプリにアクセス可能なすべてのキーチェーン項目を削除する方法に関する受け入れられた回答の Xamarin iOS バージョン (MonoTouch)は以下のとおりです。
foreach (var recordKind in new []{
SecKind.GenericPassword,
SecKind.Certificate,
SecKind.Identity,
SecKind.InternetPassword,
SecKind.Key,
})
{
SecRecord query = new SecRecord(recordKind);
SecKeyChain.Remove(query);
}
本当にレコードを削除したい場合は、開発中に次のコードを使用して、特定の種類の KeyChain 内のアイテムの数を確認することができます。
SecStatusCode scc;
var records = SecKeyChain.QueryAsRecord(new SecRecord(SecKind.GenericPassword), 1000, out scc);
于 2014-08-14T05:40:01.437 に答える
14
Daij-Djan の回答を Swift で書き直しました。
let secItemClasses = [kSecClassGenericPassword,
kSecClassInternetPassword,
kSecClassCertificate,
kSecClassKey,
kSecClassIdentity]
for secItemClass in secItemClasses {
let dictionary = [kSecClass as String:secItemClass]
SecItemDelete(dictionary as CFDictionary)
}
于 2015-11-07T04:43:32.573 に答える
7
Daij-Djan のおかげで、この解決策にたどり着きました。
for (id secclass in @[
(__bridge id)kSecClassGenericPassword,
(__bridge id)kSecClassInternetPassword,
(__bridge id)kSecClassCertificate,
(__bridge id)kSecClassKey,
(__bridge id)kSecClassIdentity]) {
NSMutableDictionary *query = [NSMutableDictionary dictionaryWithObjectsAndKeys:
secclass, (__bridge id)kSecClass,
nil];
SecItemDelete((__bridge CFDictionaryRef)query);
}
于 2012-12-29T22:02:14.437 に答える
1
Utilities フォルダにある KeyChain Access アプリケーションを見ることができます。アプリケーションを起動して [すべてのアイテム] をクリックすると、この特定のコンピューターで作成したすべてのアイテムが表示されます。開発者のものは通常、com で始まります。
于 2012-12-29T21:35:59.003 に答える