Я пытаюсь получить данные из базы данных SQLite (NSArray of strings) и заполнить содержимое в ячейках табличного представления. Я попытался выполнить запрос в командной строке, и он работает нормально. Но в коде он возвращает пустой массив.
NSString *temp = [[NSString alloc]initWithFormat:@"select img.image from images img,illness i,illness_images ii where img.img_id=ii.img_id and i.i_id=ii.i_id and i.i_id = '%d'",illid];
const char *sqlStatement = [temp UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
// Loop through the results and add them to the array
while(sqlite3_step(compiledStatement) == SQLITE_ROW)
{
// Read the data from the result row
NSString *imgname = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
[imglist addObject:imgname];
sqlite3_finalize(compiledStatement);
}
}
else{
NSAssert1(0,@"Error retrieving image names '%s'",sqlite3_errmsg(database));
}
Я попытался отладить, и когда он достигает while (sqlite3_step (compiledStatement) == SQLITE_ROW), он не входит в цикл.
Не уверен, в чем ошибка, которую я делаю.
Спасибо!