Enable Parse Local Data Store in swift

1.5k Views Asked by At

I have written this Parse.enableLocalDataStore() in my AppDelegate file after the Parse.setApplicationID() & I got error that:

Parse.Type does not have a member named 'enableLocalDataStore'

Can anyone tell me that how to create local datastore in swift for parse.

8

There are 8 best solutions below

1
On

Make sure you have Parse SDK 1.6.1. Then Parse.enableLocalDatastore() goes before Parse.setApplicationID()

0
On

Just in case...I had a similar problem, and the reason was my project's name...I was using "Parse", and I changed it to something else and now is working.

2
On

Most likely you Parse SDK is out of date. Look in the Parse.h in parse library, and if it doesn't contain the enableLocalDatastore method, you need to update your library. Follow this link to update it. Update Parse SDK

0
On

This is actually a known issue. Facebook will be providing a fix for this in the next SDK release.

0
On

From https://parse.com/docs/ios/guide#local-datastore

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    Parse.enableLocalDatastore()
    Parse.setApplicationId("parseAppId", clientKey: "parseClientKey")
  }
}

I think the order is important.

0
On

The Parse documentation states that if you wish to use local storage then you must enable this BEFORE your app/client keys in your AppDelegate.

0
On

Just in case someone comes across this question the answer is you are mistyping

enableLocalDataStore() 

you should type

enableLocalDatastore() 

The capital S makes the difference

EDIT: As some other users pointed out you have another mistake which is writting Parse.enableLocalDatastore() after setting the application ID, it should appear before. So there are, as far as I can tell those 2 mistakes.

0
On

enableLocalDataStore() before setting applicationId. This is works without any errors/warnings in the latest SDK (1.6.4)

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
   .....
    //enable local store to work when network isnt available
    Parse.enableLocalDatastore()

    //parse sdk setup
    Parse.setApplicationId("appIdGoesHere", clientKey: "clientKeyGoesHere")
    PFUser.enableAutomaticUser()

    return true
}