【发布时间】: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