Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"error: This object is not available in the offline cache" occurs only some times with Parse backend

i currently added parse backend to my ios project and defined it to work with its local data storage. it all seems to work fine except of sometimes i receive "This object is not available in the offline cache" all tough as far as i understood there is no cache at all when using local data store (enabling it in my AppDelegate like this: [Parse enableLocalDatastore];). the problem is if i reopen the app, eventually that object will be retrieved successfully. has anyone encountered this problem before?

EDIT: the order of calls i do is

PFQuery *query = [PFQuery queryWithClassName:className];
[query fromLocalDatastore];
[query whereKey:someKey equalTo:someObject];
[query includeKey:@"someKey1"];
[query includeKey:@"someKey2"];
[query orderByAscending:@"date"];
[query findObjectsInBackground];

its built for ios sdk 8.0 and parse sdk 1.7.2

thanks!

like image 670
Max Avatar asked Jun 07 '15 16:06

Max


2 Answers

You need to create a strong reference of that unavailable object prior to pinning a different object to the local datastore. Without the strong reference, the object will be flushed out from the offline cache, even though the current and different object you pinned will be saved. Hence when you re-query, you get the error message above.

like image 113
Edgardo Agno Avatar answered Oct 01 '22 22:10

Edgardo Agno


I had the same issue. My reason was that I pinned same query objects with same name at two places in my code. When I remove pin with name function and simply pin them. All work fine for me.

like image 36
bisma Avatar answered Oct 01 '22 22:10

bisma