【问题标题】:Retrieve information from Parse Local Data Store从解析本地数据存储中检索信息
【发布时间】:2017-05-12 07:55:44
【问题描述】:

我正在尝试从解析本地统计存储中检索数据。

我认为它正在固定,因为运行以下命令时没有错误:

let contact = PFObject(className: "temp")
contact["firstName"] = "steve"
contact["lastName"] = "smith"
contact["email"] = "steve.smith@example.com"
contact.pinInBackground()

尝试检索时出现错误:

let query = PFQuery(className: "temp")
query.whereKey("firstName", equalTo: "steve")
query.fromLocalDatastore()

query.findObjectsInBackground { (object, error) in

     if error == nil {
          for object in object! {
               print(object["firstName"] as! String)
          }
     }
}

返回此错误:

由于未捕获的异常而终止应用程序 'NSInternalInconsistencyException',原因:'方法需要固定 已启用。'

我在网上看了一些关于调用位置的信息

Parse.enableLocalDatastore()

在应用程序委托中,但我无法产生任何结果,并且此模板是直接来自解析的 dl,这是我的应用程序委托的第一部分:

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


//--------------------------------------
// MARK: - UIApplicationDelegate
//--------------------------------------

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Enable storing and querying data from Local Datastore.
    // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy.

    Parse.enableLocalDatastore()

    let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
        ParseMutableClientConfiguration.applicationId = "XXX"
        ParseMutableClientConfiguration.clientKey = "XXX"
        ParseMutableClientConfiguration.server = "XXX"

    })

    Parse.initialize(with: parseConfiguration)

【问题讨论】:

    标签: ios swift parse-platform parse-server


    【解决方案1】:

    排序....

     Parse.enableLocalDatastore()
    

    似乎是我从某个地方得到的遗留物品。

    只需添加:

    ParseMutableClientConfiguration.isLocalDatastoreEnabled = true
    

    解决问题。

    您需要删除或注释掉所有

    实例
    Parse.enableLocalDatastore()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-26
      • 2019-11-26
      • 1970-01-01
      相关资源
      最近更新 更多