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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.