The sample code for FMDB pretty clearly shows how FMResultSet
works. You iterate over the rows in the result set by calling the next
method at each iteration. Inside the loop, you use data access methods to retrieve the data in the column for the current row. If you want to turn this into an array, you must do it manually. Like this:
NSMutableArray *array = [NSMutableArray array]; FMResultSet *rs = [db executeQuery:@"select * from table"]; while ([rs next]) { // Get the column data for this record and put it into a custom Record object int col1 = [rs intForColumn:@"col1"]; int col2 = [rs intForColumn:@"col2"]; Record *record = [Record recordWithCol1:col1 col2:col2]; [array addObject:record]; } [rs close];
As you can see, I assume that you created your own Record
class, which represents an entry in your database table. Of course, you can also work with the dictionary.
source share