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

      <bdo id='7YUq9'></bdo><ul id='7YUq9'></ul>
    <legend id='7YUq9'><style id='7YUq9'><dir id='7YUq9'><q id='7YUq9'></q></dir></style></legend>

    <small id='7YUq9'></small><noframes id='7YUq9'>

      1. <tfoot id='7YUq9'></tfoot>
      2. iOS KeychainItemWrapper 未更新

        时间:2023-05-31

          <small id='mYwwq'></small><noframes id='mYwwq'>

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

            <tfoot id='mYwwq'></tfoot><legend id='mYwwq'><style id='mYwwq'><dir id='mYwwq'><q id='mYwwq'></q></dir></style></legend>
                1. 本文介绍了iOS KeychainItemWrapper 未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我刚刚发现我的应用程序存在一个有趣的问题.在应用程序中,我将用户的用户名和密码保存到钥匙串中.

                  I just found an interesting problem with my app. In the app I am saving the user's user name and password to the keychain.

                  keychainWrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"MyLoginPassword" accessGroup:nil];
                  
                  [keychainWrapper setObject:usernameField.text forKey:(id)kSecAttrAccount];
                  [keychainWrapper setObject:passwordField.text forKey:(id)kSecValueData];
                  

                  当这段代码在 Debug 中运行时,它似乎工作得很好.它每次都会更新,我以后可以从钥匙串中检索项目.当它在 Distribution 中运行时,钥匙串永远不会更新.我已经验证是的,这些代码行在两个版本中都被命中.我正在使用带有 iOS5 SDK 的 Xcode 4.2,并在安装了 iOS5 的 iPad 2 上运行该应用程序.

                  When this code is run in Debug it seems to work just fine. It updates each time and I can later retrieve the items from the keychain. When it is run in Distribution however the keychain never gets updated. I have verified that yes these lines of code are hit in both builds. I am using Xcode 4.2 with the iOS5 SDK and running the app on an iPad 2 with iOS5 installed.

                  推荐答案

                  我也遇到了这个问题,想了很久

                  I also had this problem, and it took me forever to figure out

                  有一个版本的KeychainWrapper"在 NSAssert 中浮动(除其他外).

                  There is a version of "KeychainWrapper" floating around that has it's SecItemUpdate within an NSAssert (among other things).

                  做这件事的人是个白痴!在为发布/分发而构建时,每个 NSAssert 都无效,这意味着代码甚至无法运行.

                  Whoever did this is a moron!, when building for release/distribution every NSAssert is nullified, meaning that code doesn't even get run.

                  例如:

                  NSAssert(SecItemUpdate((CFDictionaryRef)updateItem, (CFDictionaryRef)tempCheck), @"Couldn't update the Keychain Item." );
                  

                  需要成为

                  OSStatus status = SecItemUpdate((CFDictionaryRef)updateItem, (CFDictionaryRef)tempCheck);
                  NSAssert(status == noErr, @"Couldn't update the Keychain Item." );
                  

                  注意实际的 SecItemUpdate 是如何移动到 NSAssert 之外的,而是检查结果

                  Notice how the actual SecItemUpdate is moved outside the NSAssert, and instead the result is checked

                  重要提示:尝试更新 kSecValueData 的值,而不指定 kSecAttrAccount 的值,也会导致断言失败.因此,如果您的意图是存储单个敏感数据字符串(例如信用卡号码列表),请务必在 kSecAttrAccount 属性中存储一些帐户名称"文本,如下所示:

                  Important note: Attempting to update a value for kSecValueData, without also specifying a value for kSecAttrAccount, will cause the assertion to fail as well. So, if your intent is to store a single string of sensitive data (such as a list of credit card numbers), be sure to store some "account name" text in the kSecAttrAccount attribute, like so:

                  static NSString* kCardListXML = @"cardListXML";
                  static NSString* cardListAccountName = @"cardListAccount";
                  
                  -(void)setCardListXML:(NSString*)xml {
                    KeychainItemWrapper* wrapper =
                      [[KeychainItemWrapper alloc] initWithIdentifier:kCardListXML accessGroup:nil];
                    [wrapper setObject:cardListAccountName forKey:(id)CFBridgingRelease(kSecAttrAccount)];
                    [wrapper setObject:xml forKey:(id)CFBridgingRelease(kSecValueData)];
                  }    
                  
                  -(NSString*)getCardListXML {
                    KeychainItemWrapper* wrapper =
                      [[KeychainItemWrapper alloc] initWithIdentifier:kCardListXML accessGroup:nil];
                    [wrapper setObject:cardListAccountName forKey:(id)CFBridgingRelease(kSecAttrAccount)];
                    return [wrapper objectForKey:CFBridgingRelease(kSecValueData)];
                  }
                  

                  这篇关于iOS KeychainItemWrapper 未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:异步下载的图像仅在点击或滚动后出现在 UITabl 下一篇:支持 iPhone4 和 iPhone5 屏幕分辨率的最佳方式是什

                  相关文章

                  最新文章

                2. <small id='3s6uk'></small><noframes id='3s6uk'>

                  <tfoot id='3s6uk'></tfoot>

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

                    1. <legend id='3s6uk'><style id='3s6uk'><dir id='3s6uk'><q id='3s6uk'></q></dir></style></legend>