1

I am trying to return an NSArray after retrieving the data from Firebase. So due to several reasons, I need to have this method be synchronous rather than asynchronous. I've tried using RACSignal but I'm not sure how I can convert it to an NSArray. This is what I have so far:

- (NSArray *)premiumPlan:(NSString*)premiumId{
    Firebase *fb = [[[self.root childByAppendingPath:@"premium_plans"] childByAppendingPath:premiumId] childByAppendingPath:@"en_US"];
    return [[fb rac_valueSignal] map:^id(FDataSnapshot *snapshot) {
    NSArray *final = [[NSArray alloc]initWithObjects:snapshot.value, nil];
    return final;
}];
}

As far as I know, Firebase only has methods that retrieve data with blocks.

Eric Chuang
  • 1,017
  • 9
  • 28
  • You might want to do this with a GCD dispatch_group. https://developer.apple.com/library/ios/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html#//apple_ref/doc/uid/TP40008091-CH102-SW25 – Dare Apr 13 '16 at 18:01
  • is that the only way?? – Eric Chuang Apr 14 '16 at 04:58

0 Answers0