Open gratefulHeart opened 7 years ago
(FMDatabaseQueue )dbQueue { if (!_dbQueue) { NSString path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:_dbName]; FMDatabaseQueue *fmdb = [FMDatabaseQueue databaseQueueWithPath:path]; self.dbQueue = fmdb; [_db close]; self.db = [fmdb valueForKey:@"_db"]; } return _dbQueue; }
(instancetype)initWithDBName:(NSString )dbName path:(NSString )dbPath { if (!dbName) { dbName = @"JQFMDB.sqlite"; } NSString *path; if (!dbPath) { path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:dbName]; } else { path = dbPath; }
FMDatabase *fmdb = [FMDatabase databaseWithPath:path];
if ([fmdb open]) { self = [self init]; if (self) { self.db = fmdb; self.dbName = dbName; return self; } } return nil; }
非常感谢你的反馈, 此bug我已经修复~
(FMDatabaseQueue )dbQueue { if (!_dbQueue) { NSString path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:_dbName]; FMDatabaseQueue *fmdb = [FMDatabaseQueue databaseQueueWithPath:path]; self.dbQueue = fmdb; [_db close]; self.db = [fmdb valueForKey:@"_db"]; } return _dbQueue; }
(instancetype)initWithDBName:(NSString )dbName path:(NSString )dbPath { if (!dbName) { dbName = @"JQFMDB.sqlite"; } NSString *path; if (!dbPath) { path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:dbName]; } else { path = dbPath; }
FMDatabase *fmdb = [FMDatabase databaseWithPath:path];
if ([fmdb open]) { self = [self init]; if (self) { self.db = fmdb; self.dbName = dbName; return self; } } return nil; }