我正在开发iPhone中的应用程序,以通过sqlite访问数据库。我声明了一种从数据库检索数据的方法。此方法的返回类型是否为NSArray?在sqlite select语句之后,我们应该怎么做才能检索数据?

我的意思是在此查询之后。

NSString *selectStmt=[NSString stringWithFormat:@"select * from %@" , tableName];
sqlite3_prepare_v2(db, [selectStmt UTF8STRING] , -1, &statement, NULL);


请帮帮我。

最佳答案

NSString *selectStmt=[NSString stringWithFormat:@"select * from %@", tableName];

if( sqlite3_prepare_v2(db, [selectStmt UTF8STRING] , -1,&statement, NULL) == SQLITE_OK ) {
while( sqlite3_step(statement) == SQLITE_ROW ) {

 }
  }


在这里,您可以从sqlite获取数据并将其添加到数组中!

祝好运 !!!

10-08 08:37
查看更多