我正在BFTask
与 Parse 一起执行查询。任务内是一个嵌套查询。我希望仅在外部查询完成获取要添加的必要数据complete
(包括内部查询获取的数据)后才返回任务。我已经使用主线程实现了一个解决方案,但是我不想阻止用户界面。
+ (BFTask*)theTask {
BFTask *task = [BFTask taskFromExecutor:[BFExecutor defaultExecutor] withBlock:^id{
NSMutableArray *complete = [NSMutableArray new]; //do not return complete until it has been populated by relationObj's
[[QueryLibrary queryA] findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
for(PFObject *obj in objects) {
PFQuery *relationQuery = [obj relationForKey:@"aRelation"].query;
[relationQuery findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
for(PFObject *relationObj in objects) {
//inspect and possibly augment relationObj...
[complete addObject: relationObj];
}
}];
}
}];
return complete;
}];
return task;
}
我试图重组我的查询 ( queryA
) 以包含该关系。尝试包含关系时,出现以下错误:
+ (PFQuery *)queryA {
PFQuery *query = [PFQuery queryWithClassName:@"aPFObjectSubclass"];
//include other qualifiers...
[query includeKey:@"aRelation"]; //[Error]: field aRelation cannot be included because it is not a pointer to another object (Code: 102, Version: 1.11.0)
[query whereKeyExists:@"aRelation"]; // [Error]: Unsupported query operator on relation field: aRelation (Code: 102, Version: 1.11.0)
return query;
}