Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert FMResultSet to NSMutableArray?

I am trying out FMDB and it looks like it will work perfectly for me IF I can get my FMResultSet turned into an NSMutableArray.

How would I accomplish this?

like image 841
Slee Avatar asked Nov 30 '22 03:11

Slee


1 Answers

You could try this.

NSMutableArray *array = [NSMutableArray array];
FMDatabase *database = [FMDatabase databaseWithPath:databasePath];

[database open];

FMResultSet *results = [database executeQuery:@"SELECT * FROM Table"];
while ([results next]) {
    [array addObject:[results resultDictionary]];
}

NSLog(@"%@", array);

[database close];

I am using this in project, and it's working just fine.

like image 71
Jahm Avatar answered Dec 09 '22 16:12

Jahm