Hi Guys
I'm having a little trouble with my application being able to create a plist and load the information from that plist in the ViewDidLoad section. The code i'm using at the moment to check for the original file and if it is not there create one is as follows
(void)viewDidLoad {
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"CustomChecklist.p list"];
success = [fileManager fileExistsAtPath:filePath];
NSLog(@"STATUS OF SUCCESS %@",success);
if (!success) {
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingFormat:@"OriginalChecklist.plist"];
success = [fileManager copyItemAtPath

ath toPath:filePath];
self.dataArray = [NSMutableArray arrayWithContentsOfFile:filePath];
NSLog(@"IF STATEMENT CREATING THE FILE");
}else {
self.dataArray = [NSMutableArray arrayWithContentsOfFile:filePath];
NSLog(@"IF STATEMENT READING THE FILE");
}
NSLog(@"location information %@", filePath);
[super viewDidLoad];
}
When I build this application it builds and runs ok but I get a couple of warnings
NSFileManager may not respond to -copyItemAtPath:toPath
Once this has completed the output to the console looks as though it hasn't even checked for the file or created the one to read from.
2010-07-06 16:22:42.803 CampingChecklist[400:207] STATUS OF SUCCESS (null) 2010-07-06 16:22:42.805 CampingChecklist[400:207] IF STATEMENT READING THE FILE 2010-07-06 16:22:42.814 CampingChecklist[400:207] location information /Users/Brad/Library/Application Support/iPhone Simulator/3.1.3/Applications/E7074D5A-3E7A-4D2E-9F92-82B1A04873F8/Documents/CustomChecklist.plist
And obviously as there is nothing in the file, when it tries to save on the way out of the application it doesn't create any file in the path specified.
If anyone can shed any light on this problem then I would much appreciate it.
Thanks Brad