What is wrong in this code? NSArrays

Discussion in 'iOS Programming' started by alexandergre, Aug 8, 2009.

  1. alexandergre macrumors member

    alexandergre

    Joined:
    Jul 28, 2009
    #1
    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");
    
    		}
    }
     
  2. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #2
    What exactly is it not doing?
     
  3. ritsard macrumors regular

    ritsard

    Joined:
    Jun 18, 2009
    Location:
    SF Bay Area, CA
    #3
    Typically, you should only have one semi-colon at the end...unless this is something new.
     
  4. -aggie- macrumors P6

    -aggie-

    Joined:
    Jun 19, 2009
    Location:
    Where bunnies are welcome.
    #4
    Yes, but I doubt that would cause a problem, since it just means end of line. I just added another semi-colon to the end of one of my codings and I got no errors.
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    Still waiting for the OP to respond to post #2...
     

Share This Page