PFQuery同步调用有效,异步调用失败

PFQuery synchronous call works, asynchronous call fails

我是使用解析的新手,在查询我在解析中添加的数据时遇到了一些问题 class。我的问题是我可以让同步调用 ([query findObjects]) 工作,但是异步调用 ([queryInBackground...]) 失败了。

这是两个代码片段:

-(void)getAllDataFromParse{
    //simple query works
    PFQuery *query = [PFQuery queryWithClassName:@"wordsDB"];
    [query setLimit: 1000];
    NSArray *objects = [query findObjects];
    }
   //background query not working
   PFQuery *queryInBackground = [PFQuery queryWithClassName:@"wordsDB"];
   [queryInBackground findObjectsInBackgroundWithBlock:^(NSArray *objects2, NSError *error) {
       if (!error) {
           //query succeeds, do something
           }
       } else {
          // Log details of the failure
          NSLog(@"Error: %@ %@", error, [error userInfo]);
       }
  }];
}

这个方法在我的mainViewController中调用,调用在viewDidLoad函数的最后

[self performSelector:@selector(getAllDataFromParse)];

调试时,程序到达[queryInBackground findObjectsInBackgroundWithBlock.... ],但执行时,直接跳到方法的末尾。

我看不到任何错误消息。谁能告诉我我的异步调用出了什么问题?

我已经在模拟器和真机上试过了运行。

这是一个异步调用,意味着它将在后台继续 运行。它走到方法的末尾是完全正常的。

[queryInBackground findObjectsInBackgroundWithBlock:^(NSArray *objects2, NSError *error) {
       if (!error) {
           //query succeeds, do something
           }
       } else {
          // Log details of the failure
          NSLog(@"Error: %@ %@", error, [error userInfo]);
       }
  }];

This may also help.