Possible Duplicate:
Not able to write to Plist
I have this problem. I have a plist file named 'instellingen'. In the file, different settings are stored. For example, displaying the games rules at startup. This works just fine on the simulator but when i tested it on my iPad, the plist dat wont get saved.
here is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
plistPath = [[NSBundle mainBundle] pathForResource:@"instellingen" ofType:@"plist"];
instellingen = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
if ([[instellingen objectForKey:@"regelAtRuntime"] boolValue] == TRUE) {
[self.showRulesButton setTitle:@"Spelregels niet meer tonen" forState:UIControlStateNormal];
}else{
[self.showRulesButton setTitle:@"Spelregels wel tonen" forState:UIControlStateNormal];
}
[self.mainContent flashScrollIndicators];
}
- (IBAction)dismissRules:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)dontShowRegels:(id)sender {
if ([[instellingen objectForKey:@"regelAtRuntime"] boolValue] == TRUE) {
[instellingen setValue:@"0" forKey:@"regelAtRuntime"];
}else{
[instellingen setValue:@"1" forKey:@"regelAtRuntime"];
}
[instellingen writeToFile:plistPath atomically:YES];
}
Reading the rules from a dire rent VC seems to work fine, with this pice of code:
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"instellingen" ofType:@"plist"];
instellingen = [NSDictionary dictionaryWithContentsOfFile:plistPath];
if ([[instellingen objectForKey:@"regelAtRuntime"] boolValue] == TRUE) {
NSLog(@"We're in!");
[self performSegueWithIdentifier:@"showRulesSegue" sender:self];
}
Does anyone know what i'm doing wrong? I've tried running a clean build (Product Clean).
Any help means a lot!