【发布时间】:2011-04-16 21:12:13
【问题描述】:
如果我将数组中的数据添加到 UITableView 数据源数组中,我会在 viewDidLoad 中使用它。
NSMutableArray *array = [[NSArray alloc] initWithObjects:@"Head First Design Patterns", @"Head First HTML & CSS", @"Head First iPhone", nil];
self.transactionsArray = array;
[array release];
这个在 cellForRowAtIndexPath 中
NSInteger row = [indexPath row];
cell.textLabel.text = [transactionsArray objectAtIndex:row];
但我想链接来自选择查询的结果,我正在使用 fmdb 来访问我的数据库。以下是我目前使用 fmdb 将数据输出到控制台的方式。
FMDatabase* db = [FMDatabase databaseWithPath:@"/tmp/mydb.db"];
if (![db open]) {
NSLog(@"Could not open db.");
}
FMResultSet *rs = [db executeQuery:@"select * from myTable", nil];
while ([rs next]) {
NSLog(@"%@, %@, %@, %@, %@", [rs stringForColumn:@"pid"],
[rs stringForColumn:@"desc"],
[rs stringForColumn:@"due"],
[rs stringForColumn:@"price"],
[rs stringForColumn:@"accumulated_price"]);
}
[rs close];
[db close];
我该怎么做?
【问题讨论】:
标签: iphone sqlite uitableview iphone-sdk-3.0 fmdb