Iphone NSMutableArray有问题吗?
我初始化.h文件中的实例变量 NSInteger saveValue0、saveValue1、saveValue2、saveValue3 NSMUTABLEARRY*节点阵列 现在在.m文件中,在VIEWWILLEXPEND事件中Iphone NSMutableArray有问题吗?,iphone,Iphone,我初始化.h文件中的实例变量 NSInteger saveValue0、saveValue1、saveValue2、saveValue3 NSMUTABLEARRY*节点阵列 现在在.m文件中,在VIEWWILLEXPEND事件中 saveValue0 = 0; saveValue1 = 2; saveValue2 = 3; saveValue3 = 0; nodeArray = [[NSMutableArray alloc] initWithObjects:saveValue0, sav
saveValue0 = 0;
saveValue1 = 2;
saveValue2 = 3;
saveValue3 = 0;
nodeArray = [[NSMutableArray alloc] initWithObjects:saveValue0, saveValue1, saveValue2, saveValue3, nil];
但上述变量未插入数组中。当我尝试使用断点查看数组中的对象时,它在nodeArray中显示0个对象。为什么它会给我0个对象。有什么原因吗 NSInteger不是对象,您只能在数组中存储对象。使用[NSNumber numberWithInteger:0]等。NSInteger只是一种标准的C类型。你不能将它们添加到NSMutableArray中不出所料,这也会生成一个编译器警告:“警告:传递'initWithObjects:'的参数1会从整数生成指针而不进行强制转换”我想知道为什么RRB没有提到这一点?@Mark Bessey,对不起,是的,我忘了提到警告信息。谢谢。没有其他方法来解决我的问题。顺便说一句@RRB,你最终没有对象的原因是你的第一个数字是0,它被转换为
nil
。这是对象列表末尾的触发器。