xcode says it has no errors but it does. This code is to add Highscore to the Highscore list.
Is this really the simplest way?
Is this really the simplest way?
Code:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{
NSLog(@"Score saving cancelled");
}
else
{
NSLog(@"Adding score...");
NSMutableArray *ScoresArray= [NSMutableArray array];;
NSMutableArray *NamesArray= [NSMutableArray array];;
NSLog(@"Arrays created");
NSString *NameToSave = SaveName;
NSString *ScoreToSave= [NSString stringWithFormat:@"%d", points];
NSLog(@"Strings created");
[ScoresArray addObject:ScoreToSave];
[NamesArray addObject:NameToSave];
NSLog(@"Added to Arrays");
NSUserDefaults *ScoresDefaults =[NSUserDefaults standardUserDefaults];
[ScoresDefaults setObject:NamesArray forKey:@"NamesKey"];
[ScoresDefaults setObject:ScoresArray forKey:@"ScoresKey"];
NSLog(@"Score saved in NSUserDefaults");
}
}