DB에서 데이터를 가져 오려고하는데 문제가 있습니다.SQLite 데이터베이스에서 값을 가져 오는 방법
여기 내 코드입니다 :
NSString *action=[[NSString alloc]init];
NSString *queryStatement = [NSString stringWithFormat:@"SELECT ACTIONNAME FROM ACTIONS WHERE ACTIONSYMBOL = '%@'", symbol];
// Prepare the query for execution
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, [queryStatement UTF8String], -1, &statement, NULL) == SQLITE_OK)
{
// Create a new address from the found row
while (sqlite3_step(statement) == SQLITE_ROW) {
action = [NSString stringWithUTF8String:(char*)sqlite3_column_text(statement, 1)]; // fails on this line
}
sqlite3_finalize(statement);
return action;
}
(매개 변수 외부에서 오는 기호)
내가 이것을 실행하면, 그것은 sqlite3_column_text
결과 stringWithUTF8String
에 대한 호출과 라인에 실패합니다. 당신은 아마 NSMutableArray
의 결과를 수집 할
FMDatabase 프레임 워크를 사용하는 것이 좋습니다. sqlite의 훌륭한 래퍼입니다. – etolstoy