开发者

Can't add to NSMutableArray

开发者 https://www.devze.com 2023-03-30 10:06 出处:网络
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

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.sc开发者_Go百科oreArray addObject:@"wrong"];

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


Have you initialized array correctly?

scoreArray = [[NSMutableArray alloc] init];
0

精彩评论

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