我正在使用以下代码将 NSNumber 添加到 NSMutableArray
在头文件中:
NSNumber *timeInSeconds;
NSMutableArray *time;
在代码中:
int total=6;
timeInSeconds=[NSNumber numberWithInt:total];
[time addObject:timeInSeconds];
然而,在调试时,我注意到如果我这样做了
print (int) [time count]
我得到 0 的输出...不知道为什么会这样...任何人都可以帮助我吗?
谢谢。
最佳答案
我没看到你在哪里分配了时间
。在某些时候你需要打电话
time = [[NSMutableArray alloc] init];
或其他一些分配和初始化方法。
关于iphone - Objective-C 中的 NSMutableArray 插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6781444/