Hi, I have the following method which queries a sqlite db table on the iPhone it pulls about 6,000 rows from the table and then cycles through those creating 6,000 objects based on the information and stuffing them into an array.
The while loop is somewhat slow (takes ~ 10 seconds to iterate through them on my device) Any thoughts on how I could speed this up?
TKS!!!
NSMutableArray *dees = [[NSMutableArray alloc] init];
if(sqlite3_open([database_path UTF8String], &database) == SQLITE_OK) {
const char *sqlStatement = "select cn, gn, df, or, id from doits order by lower(cn)";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
//loop through the results and feed them into the array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSString *a_cn = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
NSString *a_gn = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *a_df = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
NSString *an_or = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];
NSString *ident = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 4)];
DL *dl = [[DL alloc] init];
dl.cn = a_cn;
dl.gn = a_gn;
dl.df = a_df;
dl.or = an_or;
dl.primary_id = [ident intValue];
[dees addObject:dl];
}
}
sqlite3_finalize(compiledStatement);