I've made an app that works with sqlite database inside the app. Before iOS 8.2 it worked fine, but after update the query method works about 100(!!!) times slower. I tried to find info about this issue but I haven't found anything yet. Is anybody has same experience? Here is my method that worked perfectly until now. Do you see any error or optimalization possibilities inside it?
Thanks for your help!
- (NSArray *)databaseContentWithQueryString:(NSString *)queryString {
NSDate *methodStart = [NSDate date];
NSMutableArray *retArray = [[NSMutableArray alloc] init];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(_database, [queryString UTF8String], -1, &statement, nil) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
int columnCount = sqlite3_column_count(statement);
NSMutableArray *valueArray = [[NSMutableArray alloc] init];
NSMutableArray *keyArray = [[NSMutableArray alloc] init];
for (int i=0; i<columnCount; i++) {
int type = sqlite3_column_type(statement, i);
char *name = (char *) sqlite3_column_name(statement, i);
[keyArray addObject:[NSString stringWithFormat:@"%s",name]];
int intVal;
char *charVal;
if (type == SQLITE_INTEGER) {
intVal = sqlite3_column_int(statement, i);
[valueArray addObject:[NSNumber numberWithInt:intVal]];
}
if (type == SQLITE_TEXT) {
charVal = (char *) sqlite3_column_text(statement, i);
[valueArray addObject:[NSString stringWithUTF8String:charVal]];
}
if (type == SQLITE_NULL) {
intVal = 0;
[valueArray addObject:[NSNumber numberWithInt:intVal]];
}
}
NSDictionary *dict = [[NSDictionary alloc] initWithObjects:valueArray forKeys:keyArray];
[retArray addObject:dict];
}
sqlite3_finalize(statement);
}
//sqlite3_close(_database);
NSDate *methodFinish = [NSDate date];
NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:methodStart];
NSLog(@"executionTime = %f s", executionTime);
return retArray;
}