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
}];
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?
This is a known bug that I have experienced when running a nested
inBackground
-type method inside anotherinBackground
-type method in Parse. The current workaround is to use a different dispatch method, such as Grand Central Dispatch.Try this:
Have you looked at their Docs on how to query local datastore :
For your reference :
https://parse.com/docs/ios_guide#localdatastore-find/iOS