if ([self OpenDB])
{
NSString *strsql;
strsql= [NSString stringWithFormat:@"SELECT COUNT(*) from NewsInfo where IsView = 0"];
const char *sqlStatement = [strsql cStringUsingEncoding:NSUTF8StringEncoding];
sqlite3_stmt *statement = nil;
if(sqlite3_prepare_v2(self.db, sqlStatement, -1, &statement, NULL) == SQLITE_OK)
{
while(sqlite3_step(statement) == SQLITE_ROW)
{
NoReadCount = (int)sqlite3_column_int(statement, 0);
}
}
// sqlite3_finalize(statement);
}
return NoReadCount;
亮点在抽取结果一定要while循环出来,否则程序崩溃