有人可以向我解释为什么这个if语句没有触发?数据库打开很好,只是我无法从数据库中检索任何值。此外,表名也是正确的。
if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil)== SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
int uniqueId = sqlite3_column_int(statement, 0);
char *nameChars = (char *) sqlite3_column_text(statement, 1);
char *addressChars = (char *) sqlite3_column_text(statement, 2);
NSString *name = [[NSString alloc] initWithUTF8String:nameChars];
NSString *address = [[NSString alloc] initWithUTF8String:addressChars];
PersonInfo *info = [[PersonInfo alloc] initWithUniqueID:uniqueId name:name address:address];
[returnArray addObject:info];
}
sqlite3_finalize(statement);
}
return returnArray;
}