0
我在設備中構建應用程序時出現性能問題。它實際上在我的數據庫中。我有一張葡萄酒細節表,其中有2114個酒名。爲了讓所有的酒的名字,我寫了這個代碼在appDelegate
:在設備中構建Objective C應用程序時的性能
-(NSMutableArray*)getWineDetails
{
[wineDetailsList removeAllObjects];
sqlite3_stmt* statement;
const char *sql = "select *from wineDetails order by name";
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) != SQLITE_OK)
{
NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
}
while (sqlite3_step(statement) == SQLITE_ROW)
{
primaryKey = sqlite3_column_int(statement, 0);
//printf("\n primaryKey1 Value:%d",primaryKey);
wineDetails *wineDets = [[wineDetails alloc] initWithPrimaryKey:primaryKey database:database];
[wineDetailsList addObject:wineDets];
//printf("\n ==========================%d",[wineDetailsList count]);
[wineDets release];
}
sqlite3_finalize(statement);
printf("\n Inside AppDelegate .....wineDetailsList count:%d",[wineDetailsList count]);
return wineDetailsList;
}
我打電話另一個控制器的viewWillAppear
,我必須顯示在酒桌上名這種方法視圖。
的viewWillAppear
代碼:
-(void)viewWillAppear:(BOOL)animated
{
CorkItAppDelegate* appDelegate = (CorkItAppDelegate*)[[UIApplication sharedApplication] delegate];
winesList = [appDelegate getWineDetails];
[tableView reloadData];
}
這裏的問題是,當我在設備構建它,它需要太多的時間來瀏覽到控制器由於日在數據庫中的金額。我該怎麼做才能擺脫這個性能問題?
謝謝,
Monish Kumar。
嗨naven, 其實我不知道數據庫中的索引。 – monish 2010-02-01 10:34:47
它是否使應用更快? – 2010-02-02 02:41:17
是的,我試圖使用index.even認爲它很慢...但它比以前更快,不使用索引。 – monish 2010-02-02 05:19:50