Enable Local Datastore - iOS Simulator app crash - Method not allowed when Pinning is enabled

I am investigating the caching / offline data use within an app design.

The first step was to add the config to the AppDelegate. Following the current iOS SDK guide, this involves:

Parse.enableLocalDatastore()

Before the call to initialize:

Parse.initialize(with: parseConfig)

The only web search result with this error, points me towards a logged GitHub issue with a recommendation to add a property to the Parse configuration, so I now also have (just before the 2 lines of code above):

let parseConfig = ParseClientConfiguration {
   $0.applicationId = "someAppId"
   $0.clientKey = "someMasterKey"
   $0.server = "http://somehost:1337/parse"
   $0.isLocalDatastoreEnabled = true
}

This is kicked off with a button press that executes a query which I would like to add to the local store / cache for future use.

let query = PFQuery(className: name)

query.cachePolicy = .cacheElseNetwork
//query.fromLocalDatastore() // I HAVE TRIED WITH THIS ADDED AND COMMENTED OUT
query.whereKey(key, contains: value)
query.includeKey("UserID")

query.findObjectsInBackground { (objects, error) in
    // CODE / LOGIC IN HERE
}

Have I structured this correctly?
Can I ask for assistance please?

Have you already tried this link? http://docs.parseplatform.org/ios/guide/#local-datastore

I believe it has all the information that you need.

Thanks, I understand enough of the issue. Caching is not the same as Pinning.

From my reading:

  • Caching helps with faster queries / querying

  • Pinning stores value into a local SQLite DB on the device itself, meaning it doesn’t need to fetch remote data - though it may be out-of-date

I removed the query.cachePolicy = .cacheElseNetwork line, as all I was looking for was the local datastore.

And once pinned, only the query.fromLocalDatastore() call needs to be added to the block of code to be executed, with no remote call made. Appropriate app logic should be considered as to how to harness this.