これが私のコードです:
-(IBAction)btnSaveInfo:(UIButton *)sender {
NSMutableArray *data = [[NSMutableArray alloc] init];
NSDictionary *appInfo = [NSDictionary dictionaryWithObjectsAndKeys: fieldAPI.text, @"App API", fieldID.text, @"App ID", fieldName.text, @"App Name", nil];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *newPath = [documentsDirectory stringByAppendingPathComponent:@"AppData.plist"];
NSMutableArray *appdata = [NSMutableArray arrayWithContentsOfFile:newPath];
[appdata addObject:appInfo];
NSLog(@"%@",appdata);
[appdata writeToFile:newPath atomically:YES];
if ([data writeToFile:newPath atomically:YES]) {
NSLog(@"Success!");
NSMutableArray *finalData = [NSMutableArray arrayWithContentsOfFile:newPath];
NSLog(@"Final array:\n\n%@",finalData);
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
else {
NSLog(@"Error...");
}
[data release];
}
私の NSLogs が返されます
2012-12-23 01:20:37.628 Parse Push[38052:c07] (
{
"App API" = asdf;
"App ID" = adsf;
"App Name" = asdf;
}
)
2012-12-23 01:20:37.932 Parse Push[38052:c07] Success!
2012-12-23 01:20:37.933 Parse Push[38052:c07] Final array:
(
)
私のコードにエラーがありますか、それとも何か不足していますか? 私は .plists とやり取りするのが初めてなので、助けていただければ幸いです。