0
SQL 데이터베이스에서 읽는 퀴즈를 만들고 레이블보기 및 텍스트 필드에 답변을 넣습니다. 비슷한 솔루션을 가진 튜토리얼을 많이 작성했지만 테이블 뷰를 사용합니다. 여기 내 시도, 나는 물론 나는 데이터베이스를 가지고 있는지 확인하고 사용 :SQL에서 데이터베이스의 데이터를 입력하고 텍스트 필드 및 레이블에 넣는 방법
-(void) readProjectsFromDatabase {
sqlite3 *database;
projects = [[NSMutableArray alloc] init];
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
const char *sqlStatement = "select * from t1";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
field1.text = [array objectAtIndex:0];
field2.text = [array objectAtIndex:1];
// Create a new project object with the data from the database
Project *project = [[Project alloc] initWithName:aName description:aDescription url:aImageUrl];
// Add the project object to the project Array
[projects addObject:project];
[project release];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
}
@OMG 포니 대물 렌즈 c – mat