i can only show last elemnts out of 10 records
qlite3 *database;
scores = [[NSMutableArray alloc] init];
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
const char *sqlStatement = "select name,score from game";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
//if(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
Book * aBook = [[Book alloc] init];
// NSString *id = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
aBook.id = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
aBook.name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
SQLiteTutorialAppDelegate *appDelegate = (SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.books = [[NSMutableArray alloc] init];
[books addObject:aBook];
// aBook.name shows all 10 names
}
}
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
now if i call this in table view like cell.text=aBook.name
so it only display last element