开发者

NSMutableArray insertion in objective-C

I am using the following code to add NSNumber to a NSMutableArray

in header file:

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 ?

Thanks.


I don't see where you allocated time. At some point you need to call

time = [[NSMutableArray alloc] init];

or some other allocation and initialization method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜