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

    <tfoot id='AItwd'></tfoot>

    <legend id='AItwd'><style id='AItwd'><dir id='AItwd'><q id='AItwd'></q></dir></style></legend>

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

        Objective C 布尔数组

        时间:2023-10-05

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

      2. <small id='vORy3'></small><noframes id='vORy3'>

            <legend id='vORy3'><style id='vORy3'><dir id='vORy3'><q id='vORy3'></q></dir></style></legend>
              <bdo id='vORy3'></bdo><ul id='vORy3'></ul>
                <tbody id='vORy3'></tbody>
              <tfoot id='vORy3'></tfoot>
                  本文介绍了Objective C 布尔数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要在objective-c 中使用一个布尔数组.我已经基本设置好了,但是编译器会在以下语句中抛出警告:

                  I need to utilize an array of booleans in objective-c. I've got it mostly set up, but the compiler throws a warning at the following statement:

                  [updated_users replaceObjectAtIndex:index withObject:YES];
                  

                  这是,我敢肯定,因为 YES 根本就不是一个对象;这是一个原始的.无论如何,我需要这样做,并且非常感谢有关如何完成它的建议.

                  This is, I'm sure, because YES is simply not an object; it's a primitive. Regardless, I need to do this, and would greatly appreciate advice on how to accomplish it.

                  谢谢.

                  推荐答案

                  没错,就是这样:NS* 容器只能存储 Objective-C 对象,不能存储原始类型.

                  Yep, that's exactly what it is: the NS* containers can only store objective-C objects, not primitive types.

                  你应该能够通过将它包装在一个 NSNumber 中来完成你想要的:

                  You should be able to accomplish what you want by wrapping it up in an NSNumber:

                  [updated_users replaceObjectAtIndex:index withObject:[NSNumber numberWithBool:YES]]

                  或使用 @(YES)BOOL 包装在 NSNumber

                  or by using @(YES) which wraps a BOOL in an NSNumber

                  [updated_users replaceObjectAtIndex:index withObject:@(YES)]]

                  然后就可以拉出boolValue了:

                  You can then pull out the boolValue:

                  BOOL mine = [[updated_users objectAtIndex:index] boolValue];

                  这篇关于Objective C 布尔数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:iOS:在 NSUserDefaults 中使用布尔值 下一篇:在 Objective-c 中,比较 2 个 BOOL 值的安全和好方法?

                  相关文章

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

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