I am writing a Parse-backed application which pulls down a catalogue of media objects (with properties and an associated PFFile) which are contained within categories. (an object can be in many categories, a category has many objects).

The app works very nicely online and through use of the Parse Cache it also has some offline functionality. (i.e. if whilst you are offline, you opt to view all objects within a category that you have previously viewed before whilst online - then some results are displayed).

I need however for users whilst offline, to be able to access objects within categories that they have not viewed before whilst online. (i.e. to be able to perform an uncached query). I initially wrote a startup/sync process which would perform a 'fetchAll' on categories and objects - hoping that this would provide me with offline access to everything. However this does not appear to be the case as when I perform a new filtered query whilst offline I get no results. (basically the problem that is described here: https://parse.com/questions/offline-subquery-of-a-cached-query).

So my question is, what is the best way to achieve this? I have considered a few different options:

  • Ray Wenderlich has a tutorial on creating a sync handler for core-data - Parse. But this seems quite complex and does not handle relationships, which is crucial for this problem

  • https://github.com/itsniper/FTASync - not looked at in any depth yet

  • reusing the fetchAll query results every time and then filtering the results array. However this could be slow and also I will not have the PFRelations for each object whilst offline.

  • Run every possible query on startup/sync so that I always have the results available offline. However the application will eventually have categories within categories so this could be a reasonable number of queries.

Any opinions/advice welcomed. Thanks

有帮助吗?

解决方案

From my experience with Parse in a similar case, I fetch all the data in a cached query and then, I have to filter/order/etc the array as I need myself with NSMutableArrays in the code.

I think that there is no way to throw querys over an offline cached query at this moment.

Just one thing: Remember that Parse querys have a limit of 1000 results. By default is set to 100 but you can modify it with setLimit. If you have more than 1000 results, you can play with setSkip method to get them in different querys..

Hope it helps

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top