alexandergre
Aug 8, 2009, 01:26 PM
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?
-(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");
}
}
Is this really the simplest way?
-(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");
}
}
