[英]NSMutableArray insertion in objective-C
I am using the following code to add NSNumber to a NSMutableArray我正在使用以下代码将 NSNumber 添加到 NSMutableArray
in header file:在 header 文件中:
NSNumber *timeInSeconds;
NSMutableArray *time;
in code:在代码中:
int total=6;
timeInSeconds=[NSNumber numberWithInt:total];
[time addObject:timeInSeconds];
However, while debugging, I noticed that if I do但是,在调试时,我注意到如果我这样做
print (int) [time count]
I get an output of 0... Not sure why this is happening...can anyone kindly help me?我得到一个 0 的 output ......不知道为什么会这样......有人可以帮助我吗?
Thanks.谢谢。
I don't see where you allocated time
.我没有看到你在哪里分配
time
。 At some point you need to call在某些时候你需要打电话
time = [[NSMutableArray alloc] init];
or some other allocation and initialization method.或其他一些分配和初始化方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.