1. <tfoot id='sJXxp'></tfoot>

          <bdo id='sJXxp'></bdo><ul id='sJXxp'></ul>

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

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

      2. iOS:在 NSUserDefaults 中使用布尔值

        iOS: Use a boolean in NSUserDefaults(iOS:在 NSUserDefaults 中使用布尔值)

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

                  <bdo id='ADolG'></bdo><ul id='ADolG'></ul>
                    <tbody id='ADolG'></tbody>

                • <legend id='ADolG'><style id='ADolG'><dir id='ADolG'><q id='ADolG'></q></dir></style></legend>
                • <i id='ADolG'><tr id='ADolG'><dt id='ADolG'><q id='ADolG'><span id='ADolG'><b id='ADolG'><form id='ADolG'><ins id='ADolG'></ins><ul id='ADolG'></ul><sub id='ADolG'></sub></form><legend id='ADolG'></legend><bdo id='ADolG'><pre id='ADolG'><center id='ADolG'></center></pre></bdo></b><th id='ADolG'></th></span></q></dt></tr></i><div id='ADolG'><tfoot id='ADolG'></tfoot><dl id='ADolG'><fieldset id='ADolG'></fieldset></dl></div>
                • <tfoot id='ADolG'></tfoot>
                  本文介绍了iOS:在 NSUserDefaults 中使用布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我的应用程序的 rootViewController 加载时,我希望能够检查用户登录凭据是否已保存到 NSUserDefaults.

                  When the rootViewController of my application is loaded, I want to be able to check whether or not the users login credentials have been saved to NSUserDefaults.

                  基本上,当用户加载应用程序并且他/她没有保存她的登录凭据时,将推送 modalAlertView 并且用户将能够适当地保存他们的凭据.这会将那些 UITextField 字符串保存到相应的 NSUserDefault 对象中.但是,是否有可能在完成此保存后,我可以创建一个 NSUserDefault 对象,它是一个布尔值并将值更改为是?

                  Basically, when the user loads the application and he/she doesn't have her login credentials saved, a modalAlertView will be pushed and the user will be able to save their credentials appropriately. This saves those UITextField strings to a respective NSUserDefault object. However, is it possible, that when this saving is done, I can create an NSUserDefault object which is a boolean and change the value to a yes?

                  意味着布尔值已经设置为否,并且当用户保存其登录凭据时,它也会将布尔值更改为是?

                  Meaning that the boolean is already set to no, and when the user saves their login credentials, it also changes the boolean to a yes?

                  推荐答案

                  您可以使用以下方法设置布尔值:

                  You can set your boolean by using:

                  [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"logged_in"];
                  [[NSUserDefaults standardUserDefaults] synchronize];
                  

                  并使用以下代码阅读:

                  if(![[NSUserDefaults standardUserDefaults] boolForKey:@"logged_in"]) {
                      [self displayLogin];
                  } else {
                      [self displayMainScreen];
                  }
                  

                  这篇关于iOS:在 NSUserDefaults 中使用布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  SharedPreferences amp; boolean(SharedPreferences amp;布尔值)
                  What values should I use for iOS boolean states?(我应该为 iOS 布尔状态使用什么值?)
                  Converting Int to Bool(将 Int 转换为 Bool)
                  Evaluate Bool property of optional object in if statement(在 if 语句中评估可选对象的 Bool 属性)
                  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 将布尔值输出为真或假?)

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

                      <tbody id='3aCm5'></tbody>
                    <legend id='3aCm5'><style id='3aCm5'><dir id='3aCm5'><q id='3aCm5'></q></dir></style></legend>

                          <bdo id='3aCm5'></bdo><ul id='3aCm5'></ul>