简体   繁体   中英

Can't add to NSMutableArray

This is getting silly and driving me crackers.

I have a small test view controller where I loop through ten questions. The answer get checked and the score goes up or stays the same. This happens in a -(void) checkAnswer. No problem!

Now comes my headache. I have a NSMutableArray declared and @property in .h It's @synthesize in .m

But when I try to add "right' or "wrong" to it in checkAnswer, nothing get added.

 [scoreArray addObject:@"wrong"];
 NSLog(@"scoreArray checkAnswer: %@",scoreArray);

There is no warnings or errors, just getting (null) from the NSLog.

Tried with no joy.

  [self.scoreArray addObject:@"wrong"];

Anyone out there that could help me? I'm sure it's something simple I can't see. Thanks

你是否正确初始化了数组?

scoreArray = [[NSMutableArray alloc] init];

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM