我在使用数据库sqlite时出现警告消息。它出现在"&数据库" 上 有什么想法吗?
sqlite3 *database;
NSLog(@"Open Database : %@", path);
// Open the database. The database was prepared outside the application.
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK)
{
NSLog(@"Open Database OK");
NSString *selectSQL = [NSString stringWithFormat:@"....
答案 0 :(得分:0)
答案:这是因为我把数据库的声明放在发货之外。
这是我的旧代码比楼上更完整:
sqlite3 *database;
NSString *path = [[self documentsDirectory] stringByAppendingPathComponent:@"tva.sqlite"];
dispatch_queue_t searchTVAQueue = dispatch_queue_create("searchTVA", NULL);
dispatch_async(searchTVAQueue, ^{
NSLog(@"Open Database : %@", path);
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK)
{
NSLog(@"Open Database OK");
NSString *selectSQL = [NSString stringWithFormat:@"....
...
这是一个很好的代码:
dispatch_queue_t searchTVAQueue = dispatch_queue_create("searchTVA", NULL);
dispatch_async(searchTVAQueue, ^{
sqlite3 *database;
NSString *path = [[self documentsDirectory] stringByAppendingPathComponent:@"tva.sqlite"];
NSLog(@"Open Database : %@", path);
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK)
{
NSLog(@"Open Database OK");
NSString *selectSQL = [NSString stringWithFormat:@"....
...
我只是将数据库声明直接包含在dispatch_async中。