保存查询的价值

时间:2012-03-22 10:09:17

标签: iphone objective-c ios

如何在NSMutableArray中保存查询中的值。

tempQuery=[@"select * from iapp_tbl_questions where id= " stringByAppendingString:[NSString stringWithFormat:@"%d",rowid1]];


const char *query2=[tempQuery UTF8String];
if (sqlite3_prepare_v2(database,query2,-1,&statement1,NULL)==SQLITE_OK) {
     NSLog(@"vt", vt);
    vt=[[[Question1 alloc]init]autorelease];
    while (sqlite3_step(statement1)==SQLITE_ROW) {

        vt.question=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement1,3)];

    }
}
return vt;

...谢谢

1 个答案:

答案 0 :(得分:0)

const char *query2=[tempQuery UTF8String];
 NSMutableArray *results = nil;
if (sqlite3_prepare_v2(database,query2,-1,&statement1,NULL)==SQLITE_OK) {
     NSLog(@"vt", vt);
    results= [[NSMutableArray alloc]init];
    while (sqlite3_step(statement1)==SQLITE_ROW) {
vt=[[[Question1 alloc]init]autorelease];
        vt.question=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement1,3)];
[results addObject:vt];

    }
}
return results;