I'm using Core Data to manage local DB in my iOS app. But then I have a requirement to insert bulk of records to local DB. So I choose FMDB to perform bulk insertion. But when I tried to insert the record I'm getting this DB Error: 1 "no such table: Table Name. But when I cross checked, the local DB exist there with all the tables that I created in xcdatamodel.
- (FMDatabase *)dbInMainThread{
if (_dbInMainThread) {
return _dbInMainThread;
}
NSURL *storeURL = [[[CoreDataManager manager] applicationLibraryDirectory] URLByAppendingPathComponent:[DATABASE_NAME stringByAppendingString:@".sqlite"]];
[self checkDB:[storeURL relativePath]];
_dbInMainThread = [FMDatabase databaseWithPath:[storeURL relativePath]];
return _dbInMainThread;
}
-(void) checkDB:(NSString *)dbpath{
BOOL success;
NSFileManager * fm = [NSFileManager defaultManager];
success = [fm fileExistsAtPath:dbpath];
if (success) return;
}
Success bool
in the above code snippet is always returning true
.
I followed the steps in this SO answer. Since I am using Core Data, I don't need to add the DB file to the project. I uninstalled the app, resets the simulator and verified the DB file was in the correct folder before starting insertion. But nothing helps.
What am I missing here
Thanks