I have developed a application and i used sq-lite database wrapper (BWDB - wrapper by Bill W.....) for my tab based application and when i create the database object at my first view controller using this code
- (DBAccess *) loadDBAccessDatabase {
// NSLog(@"%s", __FUNCTION__);
if (!_dbObject) {
NSString * _dbFileName = @"turfnutritiontool_ver_one.db";
_dbObject = [[DBAccess alloc] initWithSSDBAccessFilename:_dbFileName];
}
// Check Point
[TestFlight passCheckpoint:@"LOAD_DATABASE"];
return _dbObject;
}
and it works for me in this view controller but if i create a new object when second view Controller load so the new db object work fine for data fetch but i am not able to insert or update database it says db is lock so tell me how i can manage only one db object across all the app and send to other view controller so that it works fine,
So you are creating two objects of the class containing this code? If so, the easiest way might be to make the _dbObject
member static, as in
static DBAccess *_dbObject;
Going further, you could consider creating a singleton for the database base reference. An introduction to singletons for Cocoa is provided by Apple in Mac OS X Developer Library.