ok so i have a Plist in its SAVING fine... my problem is on a different UI i want to save DIFFERENT information... so on my first UI, a player enters his name and it saves perfect... next on a different UI i want the player to enter a value (number 0-100) and SAVE to the SAME plist... and i will use this later in the game as that players Stat tracking... but on the second UI it dosent let me save ... and the error is
-01-18 17:28:35.528 Game [7634:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (1) beyond bounds (1)'
Code:
-(NSString *)dataFilePath
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:k1Filename];
}
#pragma mark -
-(void)viewDidLoad{
NSString *filePath= [self dataFilePath];
NSLog(@"%@", filePath);
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath])
{
NSLog(@"File exist inserting coins HOPEFULLY");
NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:filePath];
child1.text = [array objectAtIndex:0];
coin1.text = [array objectAtIndex:1];// Crashes after this line of code
[array writeToFile:[self dataFilePath] atomically:YES];
//[array release];
}
else {
NSLog(@"Inside the loop4 saving coins");
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:child1.text];
[array writeToFile:[self dataFilePath] atomically:YES];
[array release];
}
UIApplication *app= [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate

name:UIApplicationWillTerminateNotification
object:app];
NSLog(@"this loads to the kids COINS");
}
-(IBAction)goPayout

id)sender
{
PayoutVC *splashMenu = [[PayoutVC alloc] initWithNibName:@"PayoutVC" bundle:nil];
NSLog(@"Does it get THIS far????? should add coin1 to plist");
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:child1.text];
[array writeToFile:[self dataFilePath] atomically:YES];
[array release];
[pKidDashboardVC.view removeFromSuperview];
[self.view addSubview:splashMenu.view];
}
As u can see its pretty standard plist, when i use this code on other UI i can PULL that child1.text FINE and save it Back to the Plist, but when i try and save the coin1.text it wont let me create a new object in the plist TOO save it... ANY help is wanted!!! thanks again
ANY information/Help would GREATLY be THANKED!!!!! Thanks again for your time!