Eric Chuang
Eric Chuang

Reputation: 1017

How can I create a synchronous method from a block in iOS

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.

Upvotes: 1

Views: 225

Answers (0)

Related Questions