开发者

NSMutableArray insertion in objective-C

开发者 https://www.devze.com 2023-03-21 21:55 出处:网络
I am using the following code to add NSNumber to a NSMutableArray in header file: NSNumber *timeInSeconds;

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

精彩评论

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