【问题标题】:Initializing an array of bools - returning null初始化 bool 数组 - 返回 null
【发布时间】:2012-04-04 12:36:17
【问题描述】:

我在初始化布尔数组时遇到了很多问题。使用NSLog 时,我不断收到(null)。我正在尝试使用 40 个 NO 设置可变数组 piecesInPlace。我已经尝试将setupArrayWithFalses 更改为YES 以进行测试,但仍然得到(null)。

BOOL setupArrayWithFalses = NO;
for (int i=0; i<40; i++) {
    [piecesInPlace addObject:[NSNumber numberWithBool:setupArrayWithFalses]];
}
NSLog(@"Value of object: %@", [piecesInPlace objectAtIndex:0]);

【问题讨论】:

    标签: objective-c ios arrays boolean


    【解决方案1】:

    你在初始化你的数组吗?

    piecesInPlace = [[NSMutableArray alloc] init];
    

    【讨论】:

      猜你喜欢
      • 2014-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多