2012-07-07 34 views
0

我有一个if语句这样为什么我的整数增加4的倍数?

@property (nonatomic) NSUInteger *theScore; 


if (hint.hidden) { 
    theScore += (2); 
     } else { 
      theScore += (1); 
       } 
NSLog(@"Score changed"); 
score.text = [NSString stringWithFormat:@"%d", theScore]; 

但是,相反的犯满离场由2或1增加它是由8个或4

任何想法增加?

回答

4

因为它是一个指向整数的指针,而不是整数本身。 4是整数的SIZE。

将其更改为NSUInteger theScore,不带*。

+0

哇,这是愚蠢的我,非常感谢 – user1282180 2012-07-07 19:18:52

相关问题