こんにちは、問題のコードと私が得ている問題です。コンパイルはできますが、強調表示した警告が添付されています。
-(void)viewdidloader
{
highscore = [[[NSUserDefaults standardUserDefaults] objectForKey:@"HIGHSCORE"]integerValue];
}
(void) differnt void
if (score>=highscore)
{
highscore = score;
//問題はこの行から始まります
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:highscore forKey:@"HIGHSCORE"]];
highscorelabel.text = [NSString stringWithFormat:@"%i",highscore ];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"NEW HIGH SCORE" message:[NSString stringWithFormat: @"Well done you got a new high score Level : %d and scored %i points" ,fred,score ] delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You Lose" message:[NSString stringWithFormat: @"Unlucky you only made it to Level : %d and scored %i points" ,fred,score ] delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
[alert release];
}
Issues
NSNumber may not respond to +number:forkey
(message without a matching method signature will be assumed to return "ID" and accept '' as an argument)
NSUserdefaukts may not respond to -setobject