const char *sql = "SELECT Nome, Nome2, Nome3 FROM libretto";
sqlite3_stmt *select_statement;
if(sqlite3_prepare_v2(database, sql, -1, &select_statement, NULL) == SQLITE_OK) {
while(sqlite3_step(select_statement) == SQLITE_ROW) {
//ricaviamo i valori letti dalla query
nome = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 0)];
nome2 = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 1)];
nome3 = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 2)];
// inseriamo tutti i valori letti in un unico oggetto
NSDictionary *dictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:nome, @"Nome", nome2, @"Nome2", nome3, @"Nome3",nil];
[listaTemp addObject:dictionary];
//inserisco tutti i valori letti dei nomi in un unico oggetto
[listaTemp addObject:dictionary];
}
}
sqlite3_finalize(select_statement);
我的问题是每次都在
name = [NSString stringWithUTF8String: (char *)
sqlite3_column_text (select_statement, 0)];
我总是读取数据库中的姓氏。
我希望您以不同的NSString
中的前三个名字保存我,以便它可以用来执行我的比较。
const char *sql = "SELECT Nome, Nome2, Nome3 FROM libretto";
sqlite3_stmt *select_statement;