Hi everyone,
I'm working on an app that exchanges data with a server, and the mobile device has an option to wipe the database clean.
I manage to delete the .sqlite, but I cannot copy the fresh one.
I keep getting a "nil" for the NSString *param variable, and I can't understand why. Of course the following copyItemAtURL fails.
Besides, the whole code block is inside a try/catch, but the code inside the catch is not being executed.
Any clue? Code is as follows:
NSError* err = nil;
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = @"BaseScope";
NSString *type = @"sqlite";
NSString *param = [bundle pathForResource:path ofType:type];
if (param != nil)
{
NSURL *preloadURL = [NSURL fileURLWithPath:param isDirectory:false];
if (![[NSFileManager defaultManager] copyItemAtURL:preloadURL toURL:storeURL error:&err])
{
//some code
}
}