2012-07-07 31 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

相關問題