每次击杀时都试图计算一个分数,每次击杀都加 5 分,但是,它从不添加值,因此即使在额外击杀后也卡在 5 分。以下是我的数组代码。
NSMutableArray * scoreTally = [NSMutableArray array];
NSNumber *scoreValue = [NSNumber numberWithInteger:5];
[scoreTally addObject:scoreValue];
int sum=0;
for(int x=0; x < [scoreTally count]; x++)
{
sum += [[scoreTally objectAtIndex:x] intValue];
}
NSLog(@"SUM %D",sum);
score.text = [NSString stringWithFormat:@"Score: %d",sum];