0

I'm trying to call below parse retrieving method in another dispatch block but it never calls. I'm suspect calling a block in another block doesn't allowed but not sure. Does anybody have any idea about why findObjectsInBackgroundWithBlock isn't called?

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
PFQuery *query = [PFQuery queryWithClassName:@"quotes"];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
            if (!error) {

            NSMutableArray *tempQuotes = [[NSMutableArray alloc] init];
            for (PFObject *object in objects) {

                [tempQuotes addObject:[object objectForKey:@"quote"]];
            }

            quotes = tempQuotes;

        }
    }];

 dispatch_async(dispatch_get_main_queue(), ^{

        [self.delegate postRefreshing];
    });
});
vrwim
  • 13,020
  • 13
  • 63
  • 118
mehmeet43
  • 183
  • 15

1 Answers1

0

I changed my inner parse query as below (without any background block) and it worked. I should know that you can't call a method in background if you are already in a dispatch block.

PFQuery *query = [PFQuery queryWithClassName:@"quotes"];
NSArray* quotesArray = [query findObjects];
mehmeet43
  • 183
  • 15
  • FYI: Dispatching a block inside another dispatched block is definitely supported by GCD. If this doesn't work, it must be something in the Parse framework or some other code. – Rengers Mar 23 '15 at 16:18
  • Maybe there is something in the Parse but above implementation works for me for now. Thanks. – mehmeet43 Mar 23 '15 at 18:47