Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alexandergre

macrumors member
Original poster
Jul 28, 2009
58
0
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?
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");

		}
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.