简体   繁体   English

无法启用解析本地数据存储

[英]Can't enable Parse Local Datastore

I'm trying enable the Parse Local Datastore. 我正在尝试启用“解析本地数据存储”。 In the Parse Docs, they said to put the code enableLocalDatastore before setApplicationId:clientKey: , but this throws an exception: 他们说,在Parse Docs中,将代码enableLocalDatastore放在setApplicationId:clientKey: 之前 ,但这会引发异常:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You have to call setApplicationId:clientKey: on Parse to configure Parse.' 由于未捕获的异常“ NSInternalInconsistencyException”而终止应用程序,原因:“您必须在Parse上调用setApplicationId:clientKey:才能配置Parse。”

v1.6.0 v1.6.0

Place the code for enableLocalDatastore after setting applicationId and clientKey. 在设置applicationId和clientKey之后,放置enableLocalDatastore的代码。 It looks like it was simply a mistake in their documentation. 看来这只是他们文档中的一个错误。

v1.6.1+ v1.6.1 +

Place the code for enableLocalDatastore before setting applicationId and clientKey. 在设置applicationId和clientKey之前,将代码放入enableLocalDatastore。

Just be sure you don't have any cachePolicy set in your code. 只要确保您的代码中没有设置任何cachePolicy即可。 In my case I had 就我而言

query.cachePolicy = kPFCachePolicyNetworkElseCache

There is not need of a cache now you have your data in a local database. 现在您将数据存储在本地数据库中,因此无需缓存。

I was having the same error. 我有同样的错误。

I commented this line" // query.cachePolicy = PFCachePolicy.CacheElseNetwork" and it works. 我注释了这一行“ // query.cachePolicy = PFCachePolicy.CacheElseNetwork”,它可以正常工作。

override func queryForTable() -> PFQuery {
let query: PFQuery = PFQuery(className: self.parseClassName!)
if(objects?.count == 0){
   //query.cachePolicy = PFCachePolicy.CacheElseNetwork
    }
    query.orderByAscending(Column Name")
    return query
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM