I am trying to create a plist file that I will write to later in my app. In the first viewDidLoad I call the following method
-(void)createFavoritesFile{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentDBFolderPath = [documentsDirectory stringByAppendingPathComponent:@"data.plist"];
if (![fileManager fileExistsAtPath:documentDBFolderPath])
{
NSLog(@"file doesnt exist");
NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"data.plist"];
[fileManager copyItemAtPath:resourceDBFolderPath toPath:documentDBFolderPath error:&error];
}
else{
NSLog(@"file exists");
}
}
However every time I run the app, I cannot find a file created, and if I close the app and reopen, NSLog shows that file doesnt exist again. Am I missing something?