I want to start using FMDatabaseQueue to run queries in different threads within my application simultaneously, but I'm not sure how to implement a read action within a method. I'm using the example found here: http://ccgus.github.io/fmdb/html/Classes/FMDatabaseQueue.html
How can I implement this snippet within a method so it runs synchronous and returns the results?
FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:aPath];
[queue inDatabase:^(FMDatabase *db) {
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:1]];
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:2]];
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:3]];
FMResultSet *rs = [db executeQuery:@"select * from foo"];
while ([rs next]) {
//…
}
}];
Edit: to clarify, I want to either return the resultset or an NSArray I fill myself