I have an ipad app using core data in which the data store is preloaded on first load. Today i needed to make some changes in the database and after doing so, my code that loads the datastore does not find the resource. I have copied the resource into the project directory and verified that it does exist and is spelled properly. Here is the code that loads the DB
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"SpokeCalcMD.sqlite"];
if(![[NSFileManager defaultManager] fileExistsAtPath:[storeURL path]]){
//fails at this line
NSURL *preloadURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"SpokeCalcMD" ofType:@"sqlite"]];
NSLog(@"PRELOAD URL: %@", preloadURL);
NSError *err = nil;
if(![[NSFileManager defaultManager] copyItemAtURL:preloadURL toURL:storeURL error:&err]){
NSLog(@"FAILED TO COPY DATABASE");
}
}
Produces the following:
ERROR: 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
I have taken all the normal steps, project clean, reset simulator. Any suggestions? Thanks!