8

In Parse docs, it clearly states that [Parse enableLocalDatastore]; should be called before [Parse setApplicationId:clientKey:];: https://parse.com/docs/ios_guide#localdatastore-find/iOS

However, in my case, it immediately throws an exception:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You have to call setApplicationId:clientKey: on Parse to configure Parse.'

If I move the code to execute after [Parse setApplicationId:clientKey:]; I don' get an error, but local store doesn't seem to work.

Seems that Parse's own docs are misleading. Anyone got a solution?

Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
  • You're right that there is something wrong there. It appears you have to call `setApplicationId:clientKey:` before calling `enableLocalDatastore`, or you will indeed see that exception. However, the local data store works for me. – rickerbh Dec 12 '14 at 02:45
  • My findings are the same as @rickerbh – Carl Dec 12 '14 at 13:28

3 Answers3

5

I put the [Parse enableLocalDatastore]; after the [Parse setApplicationId:clientKey:]; and i got another errors. But this another errors was because you can't use Local Datastore and Cache Policy together. When i removed the Cache Policy's methods everything works fine. So, i don't know if this is a documentation mistake, but you have to put this code after.

  • Yeah, probably a documentation error. Weird that it is explicitly noted at different places of the documentation though. – Can Poyrazoğlu Dec 14 '14 at 20:00
  • I've opened an issue in facebook too, and they reported that they will release a fix soon. – Henrique Güttler Morbin Dec 15 '14 at 17:15
  • @HenriqueGüttlerMorbin is it better to use localDataStore, or implement cachePolicy yourself? – SamYoungNY Nov 11 '15 at 19:43
  • @SamYoungNY I have a lot of application using Parse, but I have not any in production using localDataStore yet. So I am still using, and I preffer the Cache Policy from the Parse SDK. It is mature and works very well. I have a good background using Parse Plataform, so if you need some help, please, let me know. – Henrique Güttler Morbin Nov 11 '15 at 20:52
  • @HenriqueGüttlerMorbin thanks for the explanation I will keep that in mind. – SamYoungNY Nov 12 '15 at 19:20
2

This should be fixed in the new v1.6.1 version of the Parse SDK.

Héctor Ramos
  • 9,239
  • 6
  • 36
  • 39
0

Remove the cache policy on your query.

The error is not descriptive enough, but what it means is "cache policy is not allowed when Pinning is enabled". Continue to enable pinning before setting application id and client key.

Change from

query.cachePolicy = PFCachePolicy.CacheThenNetwork

To this

query.fromLocalDatastore()
Michael Peterson
  • 10,383
  • 3
  • 54
  • 51