我有一个数据库有5个记录,我需要使用计时器逐个显示屏幕上的记录。时间间隔应该是30秒。NSTimer:如何使用它到数据库
- (NSMutableArray*) fnGetName
{
DBCon *oDBCon = [[DBCon alloc] init];
[oDBCon fnInitializeDB];
NSMutableArray *arrDict = [[NSMutableArray alloc] init];
NSString *sQryName = [NSString stringWithFormat:@"SELECT * FROM tbl_names"];
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(oDBCon.database, [sQryName UTF8String], -1, &selectstmt, NULL) == SQLITE_OK)
{
while(sqlite3_step(selectstmt) == SQLITE_ROW) {
oBlossom = [[Blossom alloc]initWithPrimaryKey:primaryKey database:oDBCon.database];
oBlossom.psName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,1)];
NSLog(@"oBlossom.psName %@", oBlossom.psName);
oBlossom.psKeyword = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,2)];
NSLog(@"oBlossom.psKeyword %@", oBlossom.psKeyword);
[arrDict addObject:oBlossom];
}
希望这个链接将帮助你。 [这里](http://stackoverflow.com/questions/8164095/call-a-function-once-per-second-for-10-seconds)! – 2012-08-03 10:51:35