Domanda

I have an if statement like this

@property (nonatomic) NSUInteger *theScore;


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

But instead of theScore increasing by 2 or 1 it's increasing by 8 or 4

Any ideas?

È stato utile?

Soluzione

Because it's a pointer to the integer, not the integer itself. The 4 is the SIZE of the integer.

Change it to NSUInteger theScore, without the *.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top