i receive this exception after calling the following method. And it only comes when app load for the first time. When i again open the app it works fine. Can anyone help?
-(void) createAndCheckDatabase
{
BOOL success;
self.databaseName = @"database.db";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir = [documentPaths objectAtIndex:0];
self.databasePath = [[documentDir stringByAppendingPathComponent:self.databaseName]retain];
NSFileManager *fileManager = [NSFileManager defaultManager];
success = [fileManager fileExistsAtPath:self.databasePath];
if(success) return;
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:self.databaseName];
NSError *err;
[fileManager copyItemAtPath:databasePathFromApp toPath:self.databasePath error:nil];
if (err) {
// DebugLog(@"%@", [err description]);
}
}
if (err) … will crash because err is not initialized! and you dont use it in fileManager copyItemAtPath: