
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.79 KB | hits: 9 | expires: Never
Outrageous scores values
-(id)init{
self = [super init];
if (self != nil) {
int score;
_score = score;
self.scoreLabel.string = [NSString stringWithFormat:@"Score: %d",_score];
// 6
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger highScore = [defaults integerForKey:@"BatHighScore"];
// 7
if(score >= highScore) {
highScore = score;
[defaults setInteger:score forKey:@"BatHighScore"];
[defaults synchronize];
}
self.highScoreLabel.string = [NSString stringWithFormat:@"High: %d",highScore]
}
return self;
}
@end
int score; // garbage
_score = score;
-(id)initWithScore:(NSInteger)score {
self = [super init];
if (self != nil) {
_score = score;
// ...