There is a resultDict method defined in the FMResultSet class. I would do it like this:
FMResultSet *rs = [db executeQuery:@"SELECT Name, Age, FROM PersonList"]; while ([rs next]) { NSLog(@"%@", [[rs resultDict] description]); }
This should print something like:
{ Name = bbbbbird1; Age = 25; }
for each row of the PersonList table. Now there are two ways to enter these values into an array. One of them is to use the allValues NSDictionary method, however, the column order is likely to be upset. Another way is to build the array yourself:
FMResultSet *rs = [db executeQuery:@"SELECT Name, Age, FROM PersonList"]; while ([rs next]) { NSMutableArray* rowData = [[NSMutableArray alloc] init]; for(int i=0; i<[s columnCount]; i++) { [rowData addObject:[[rs resultDict] objectForKey:[[rs columnNameForIndex:i] lowercaseString]]; } NSLog(@"%@", [rowData description]); }
The above should print:
( bbbbbird1, 25 )
Hope this is what you are looking for. You can put this code in the FMResultsSet category if you need to have strings as arrays in many places in your application.
source share