If I was adding data from an array to the UITableView datasource array I'd use this, in viewDidLoad.
NSMutableArray *array = [[NSArray alloc] initWithObjects:@"Head First Design Patterns", @"Head First HTML & CSS", @"Head First iPhone", nil];
self.transactionsArray = array;
[array release];
And this in cellForRowAtIndexPath
NSInteger row = [indexPath row];
cell.textLabel.text = [transactionsArray objectAtIndex:row];
But I want to link up the results from a select query, I'm using fmdb to access my database. Heres how I output data to the console with fmdb at the moment.
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];
How do i do this ?