0
我只能顯示出10條記錄sqlite的記錄不會顯示爲iPhone
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);
現在
最後elemnts如果我把這個像cell.text=aBook.name
表視圖,以便只顯示最後一個元素
嘿,我就照你說的,但現在我可以看到所有的10個記錄的同名plz幫助 我這樣做之前,while循環書* ABOOK = [[書頁頭] INIT ]。 \t \t SQLiteTutorialAppDelegate * appDelegate =(SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate]; \t \t appDelegate.books = [[NSMutableArray alloc] init]; – ram 2010-07-07 01:14:03
完美ü拯救了我的生命,以你的知識帽子:-) – ram 2010-07-07 01:25:49