gpt4 book ai didi

ios - 从解析本地数据存储检索信息

转载 作者:行者123 更新时间:2023-11-30 12:48:08 24 4
gpt4 key购买 nike

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

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

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)
}
}
}

返回此错误:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Method requires Pinning enabled.'

我在网上阅读了一些有关

的调用位置的信息
Parse.enableLocalDatastore()

在应用程序委托(delegate)中,但我无法生成任何结果,并且此模板是直接从解析中获取的,这是我的应用程序委托(delegate)的第一部分:

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)

最佳答案

已排序...

 Parse.enableLocalDatastore()

似乎是我从某处得到的遗留元素。

只需添加:

ParseMutableClientConfiguration.isLocalDatastoreEnabled = true

解决了问题。

您需要删除或注释掉

的所有实例
Parse.enableLocalDatastore()

关于ios - 从解析本地数据存储检索信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41355164/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com