gpt4 book ai didi

objective-c - 初始化 boolean 数组 - 返回 null

转载 作者:行者123 更新时间:2023-11-28 18:42:00 28 4
gpt4 key购买 nike

我在初始化 boolean 值数组时遇到了很多问题。使用 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]);

最佳答案

你在初始化你的数组吗?

piecesInPlace = [[NSMutableArray alloc] init];

关于objective-c - 初始化 boolean 数组 - 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10011221/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com