Salve a tutti, ho veramente bisogno del costro aiuto!
Ho un database SQLite dal nome dizionario.sqlite incluso nel mio progetto xcode per iphone.
Questo è il mio codice in cui richiamo il database.
sqlite3 *database;
NSString *path = [[NSBundle mainBundle] pathForResource:@"dizionario" ofType:@"sqlite"];
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK)
{
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, "SELECT * FROM ita where Mapping=?", -1, &statement, NULL) == SQLITE_OK)
{
sqlite3_bind_int(statement, 1, [utftesto.text intValue]);
if (sqlite3_step(statement) == SQLITE_ROW)
{
char *testo = (char *)sqlite3_column_text(statement, 0);
if (testo!=nil)
utwtesto.text = [NSString stringWithUTF8String:testo];
else
utwtesto.text = @"";
}
else
{
NSLog (@"Parola inesistente");
}
}
else
{
NSLog(@"DB: query KO");
return @"a";
}
sqlite3_finalize(statement);
sqlite3_close(database);
}
Notate che la query che sto utilizzanto ricerca dentro il Campo Mapping dal campo utftesto.
Es.
Se mapping=125456 come posso dirgli di restituirmi il valore anche se il campo utftesto.text=12
In parole povere voglio un funzionamento simile quello di spootlight di leopard restituisce i valori man mano che scrivi.