-1

I need to load database: shortSelected - string, array - array of strings, date - date.

I load database from shortSelected(it string that always different) and database has all that values, I pass shortSelected to database, but in 3 string resultSet=nil. What is wrong?

FMDatabase *database = [FMDatabase sharedInstance];
NSMutableArray *results = [NSMutableArray array];
FMResultSet *resultSet = [database executeQuery:@"SELECT * FROM rss WHERE name = shortSelected"];
NSArray *resultArray = [resultSet objectForColumnName:@"array"];
NSDate *resultDate = [resultSet dateForColumn:@"date"];
[results addObject:resultArray];
[results addObject:resultDate];
self.data = results;
NSLog(@"%@", _data[0][shortSelected]);
Unheilig
  • 16,196
  • 193
  • 68
  • 98
user3121912
  • 385
  • 1
  • 3
  • 6

1 Answers1

2

You need to call next method to confirm whether there is data in the set, then to read the data. code should be

while([resultSet next])
{
   NSArray *resultArray = [resultSet objectForColumnName:@"array"];
   NSDate *resultDate = [resultSet dateForColumn:@"date"];
   [results addObject:resultArray];
   [results addObject:resultDate];
}
chancyWu
  • 14,073
  • 11
  • 62
  • 81