I am using FMDB to select data in SQLite3 and the result is saved in FMResultSet, I tried to add it to NSMutableArray and use it later, but it seems like the FMResultSet can't be used, does anyone tell me why?
Code:
FMDatabase *db = [FMDatabase databaseWithPath:pathInDocumentsFolder(kDatabase)];
if (![db open]) {
NSLog(@"Could not open db.");
return;
}
FMResultSet *rs = [db executeQuery:@"SELECT date, open, high, low, close, volume FROM stock_t1 WHERE code = ? ORDER BY date DESC", stockCode.code];
[stockDataList release];
stockDataList = nil;
stockDataList = [[NSMutableArray alloc] init];
while ([rs next]) {
[stockDataList addObject:rs];
}
[rs close];
[db close];
Code:
FMResultSet *stock = [stockDataList objectAtIndex:indexPath.row];//no correct result
cell.labelDate.text = [stock stringForColumn:@"date"];
cell.labelOpen.text = [stock stringForColumn:@"open"];
cell.labelHigh.text = [stock stringForColumn:@"high"];
cell.labelLow.text = [stock stringForColumn:@"low"];
cell.labelClose.text = [stock stringForColumn:@"close"];
cell.labelVolume.text = [stock stringForColumn:@"volume"];