Reputation: 85
I'm trying to retrieve local datastore in swift Parse SDK the following way:
let query = PFQuery(className: "Cliente")
query.fromLocalDatastore()
do{
object = try query.getFirstObject()
}
catch{
return nil
}
But when fromLocalDatastore() is called, in saw the follow exception:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Method requires Pinning enabled.'
In my AppDelegate, I'm calling Parse.enableLocalDatastore() before Parse configuration, like that:
Parse.enableLocalDatastore()
let configuration = ParseClientConfiguration{
$0.applicationId = "FF6itU7EzyH7dN10IL2KERRddpC7HYZUdTIA7HYV"
$0.clientKey = "eQLh9J92OKMydnflk5VNFOVZnlkzLvCgVKQ6QtLr"
//$0.server = ""
}
Parse.initializeWithConfiguration(configuration)
In some places, I saw suggestions to put $0.localDatastoreEnabled = true inside ParseClientConfiguration but it didn't work too.
And also, I can't to do that: configuration.localDatastoreEnabled = true because it is a get-only.
Have you another suggestions?
Upvotes: 3
Views: 406
Reputation: 2788
in order to use local data store you need to do 2 things:
let gameScore = PFObject(className:"GameScore")
gameScore["score"] = 1337
gameScore["playerName"] = "Sean Plott"
gameScore["cheatMode"] = false
gameScore.pinInBackground()
the pinInBackground() method will pin this object to the local data store and after you pin it you can then get it from the local data store via your code.
Upvotes: 2