• <legend id='2zCR1'><style id='2zCR1'><dir id='2zCR1'><q id='2zCR1'></q></dir></style></legend>
    <i id='2zCR1'><tr id='2zCR1'><dt id='2zCR1'><q id='2zCR1'><span id='2zCR1'><b id='2zCR1'><form id='2zCR1'><ins id='2zCR1'></ins><ul id='2zCR1'></ul><sub id='2zCR1'></sub></form><legend id='2zCR1'></legend><bdo id='2zCR1'><pre id='2zCR1'><center id='2zCR1'></center></pre></bdo></b><th id='2zCR1'></th></span></q></dt></tr></i><div id='2zCR1'><tfoot id='2zCR1'></tfoot><dl id='2zCR1'><fieldset id='2zCR1'></fieldset></dl></div>

    <small id='2zCR1'></small><noframes id='2zCR1'>

        • <bdo id='2zCR1'></bdo><ul id='2zCR1'></ul>

      1. <tfoot id='2zCR1'></tfoot>
      2. 如何重置 iPhone 应用的钥匙串?

        How do you reset an iPhone App#39;s Keychain?(如何重置 iPhone 应用的钥匙串?)
        • <i id='3bZxA'><tr id='3bZxA'><dt id='3bZxA'><q id='3bZxA'><span id='3bZxA'><b id='3bZxA'><form id='3bZxA'><ins id='3bZxA'></ins><ul id='3bZxA'></ul><sub id='3bZxA'></sub></form><legend id='3bZxA'></legend><bdo id='3bZxA'><pre id='3bZxA'><center id='3bZxA'></center></pre></bdo></b><th id='3bZxA'></th></span></q></dt></tr></i><div id='3bZxA'><tfoot id='3bZxA'></tfoot><dl id='3bZxA'><fieldset id='3bZxA'></fieldset></dl></div>
            <tbody id='3bZxA'></tbody>

          1. <tfoot id='3bZxA'></tfoot>
            • <bdo id='3bZxA'></bdo><ul id='3bZxA'></ul>

                <small id='3bZxA'></small><noframes id='3bZxA'>

                  <legend id='3bZxA'><style id='3bZxA'><dir id='3bZxA'><q id='3bZxA'></q></dir></style></legend>
                  本文介绍了如何重置 iPhone 应用的钥匙串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道是否有办法重置我的应用的钥匙串.我想知道钥匙串是否存在类似 [NSUserDefaults resetStandardUserDefaults] 的东西.即使删除应用程序后,钥匙串也不会重置.到目前为止,我知道的唯一方法是从应用程序中一一重置它们.

                  I would like to know if there is a way to reset my app's Keychain. I am wondering whether anything like [NSUserDefaults resetStandardUserDefaults] exists for keychain. Keychain is not reset even after the app is deleted. So far the only way I know is to reset them one by one from the app.

                  推荐答案

                  由于到目前为止所有的答案都依赖于您知道要删除的标识符,我想提交以下解决方案,删除所有现有的应用键(仅限 iOS)

                  As all of the answers so far rely on you knowing the identifiers you want to delete, I would like to submit the following solution that deletes ALL existing keys for the app (iOS only)

                  目标-C:

                  -(void)resetKeychain {
                      [self deleteAllKeysForSecClass:kSecClassGenericPassword];
                      [self deleteAllKeysForSecClass:kSecClassInternetPassword];
                      [self deleteAllKeysForSecClass:kSecClassCertificate];
                      [self deleteAllKeysForSecClass:kSecClassKey];
                      [self deleteAllKeysForSecClass:kSecClassIdentity];
                  }
                  
                  -(void)deleteAllKeysForSecClass:(CFTypeRef)secClass {
                      NSMutableDictionary* dict = [NSMutableDictionary dictionary];
                      [dict setObject:(__bridge id)secClass forKey:(__bridge id)kSecClass];
                      OSStatus result = SecItemDelete((__bridge CFDictionaryRef) dict);
                      NSAssert(result == noErr || result == errSecItemNotFound, @"Error deleting keychain data (%ld)", result);
                  }
                  

                  Swift 2.2:

                  func resetKeychain() {
                      self.deleteAllKeysForSecClass(kSecClassGenericPassword)
                      self.deleteAllKeysForSecClass(kSecClassInternetPassword)
                      self.deleteAllKeysForSecClass(kSecClassCertificate)
                      self.deleteAllKeysForSecClass(kSecClassKey)
                      self.deleteAllKeysForSecClass(kSecClassIdentity)
                  }
                  
                  func deleteAllKeysForSecClass(secClass: CFTypeRef) {
                      let dict: [NSString : AnyObject] = [kSecClass : secClass]
                      let result = SecItemDelete(dict)
                      assert(result == noErr || result == errSecItemNotFound, "Error deleting keychain data ((result))")
                  }
                  

                  斯威夫特 3:

                  func resetKeychain() {
                      deleteAllKeysForSecClass(kSecClassGenericPassword)
                      deleteAllKeysForSecClass(kSecClassInternetPassword)
                      deleteAllKeysForSecClass(kSecClassCertificate)
                      deleteAllKeysForSecClass(kSecClassKey)
                      deleteAllKeysForSecClass(kSecClassIdentity)
                  }
                  
                  func deleteAllKeysForSecClass(_ secClass: CFTypeRef) {
                      let dict: [NSString : Any] = [kSecClass : secClass]
                      let result = SecItemDelete(dict as CFDictionary)
                      assert(result == noErr || result == errSecItemNotFound, "Error deleting keychain data ((result))")
                  }
                  

                  这篇关于如何重置 iPhone 应用的钥匙串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What values should I use for iOS boolean states?(我应该为 iOS 布尔状态使用什么值?)
                  Why does Objective-C use YES/NO macro convention instead of true/false?(为什么 Objective-C 使用 YES/NO 宏约定而不是 true/false?)
                  How do I get NSJSONSerialization to output a boolean as true or false?(如何让 NSJSONSerialization 将布尔值输出为真或假?)
                  Is there any difference between bool, Boolean, and BOOL in Objective-C?(Objective-C 中的 bool、Boolean 和 BOOL 之间有什么区别吗?)
                  BOOL to NSString(布尔到 NSString)
                  Set bool property of all objects in the array(设置数组中所有对象的布尔属性)
                  <legend id='TDlKT'><style id='TDlKT'><dir id='TDlKT'><q id='TDlKT'></q></dir></style></legend>
                    • <bdo id='TDlKT'></bdo><ul id='TDlKT'></ul>
                    • <small id='TDlKT'></small><noframes id='TDlKT'>

                        <i id='TDlKT'><tr id='TDlKT'><dt id='TDlKT'><q id='TDlKT'><span id='TDlKT'><b id='TDlKT'><form id='TDlKT'><ins id='TDlKT'></ins><ul id='TDlKT'></ul><sub id='TDlKT'></sub></form><legend id='TDlKT'></legend><bdo id='TDlKT'><pre id='TDlKT'><center id='TDlKT'></center></pre></bdo></b><th id='TDlKT'></th></span></q></dt></tr></i><div id='TDlKT'><tfoot id='TDlKT'></tfoot><dl id='TDlKT'><fieldset id='TDlKT'></fieldset></dl></div>
                          <tbody id='TDlKT'></tbody>
                        <tfoot id='TDlKT'></tfoot>