问题描述
我有一个Parse应用程序,我想启用本地数据存储以进行缓存/脱机使用。在我的app委托中,我设置了 [Parse enableLocalDatastore];
。
I have a Parse app and I want to enable local data store for caching/offline use. In my app delegate, I've set [Parse enableLocalDatastore];
.
在我的查询中(到服务器) ),我正在进行正常查询,但是我在获取结果时固定结果:
In my query (to the server), I'm making a normal query, but I'm pinning the results upon fetch:
[followingsQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[PFObject pinAllInBackground:objects block:^(BOOL succeeded, NSError *error) {
NSLog(@"er: %@", error);
}];
... //rest of my handler
}];
然而,完成块( NSLog(@er:%@) ,错误);
)永远不会被调用。甚至没有错误。我到处都有断点。 pinAllInBackground:block:
被调用,但它的完成处理程序从未被调用(我的应用程序已连续运行2分钟,它只固定100个对象,所以它应该是瞬时的)。我也试过 pinAllInBackground:withName:block:
但没有区别。我试过 pinAll:
并且它永远不会返回,阻塞调用线程(虽然它不消耗任何CPU)。我该如何解决这个问题?
However, the completion block (NSLog(@"er: %@", error);
) is never called. Not even with an error. I've got breakpoints everywhere. pinAllInBackground:block:
is called, but it's completion handler is never called (my app's been running for 2 minutes straight, it's pinning only 100 objects, so it should be instantaneous). I've also tried pinAllInBackground:withName:block:
but no difference. I've tried pinAll:
and it just never returns, blocking the calling thread (it doesn't consume any CPU though). How can I solve this problem?
推荐答案
这是我在运行嵌套在Parse中的另一个 inBackground
-type方法中的inBackground -type方法。目前的解决方法是使用不同的调度方法,例如Grand Central Dispatch。
This is a known bug that I have experienced when running a nested inBackground
-type method inside another inBackground
-type method in Parse. The current workaround is to use a different dispatch method, such as Grand Central Dispatch.
试试这个:
[followingsQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
NSError *error = nil;
id result = [PFObject pinAll:objects error:&error];
if (error) {
NSLog("error: %@", error);
}
});
}];
这篇关于PFQuery pinAllInBackground:block:永远不会完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!