【问题标题】:Swift - 1.2, Parse - 1.7.4, CachePolicy斯威夫特 - 1.2,解析 - 1.7.4,缓存策略
【发布时间】:2015-06-29 20:28:46
【问题描述】:

我正在尝试从 Parse 数据库中检索查询;但是,当我运行应用程序并单击按钮转到将从数据库中检索数据的视图控制器时,我的应用程序崩溃了。当应用程序崩溃时,我会收到 AppDelegate.swift 文件。

这是错误:由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“启用固定时不允许方法。”

我确保在我的项目中正确实施 Parse。此外,当我取出 if self.objects.count == 0 {} 代码块时,当我转到从数据库中检索数据的视图控制器时,应用程序运行良好。但只有这一次,当我的解析数据库中有对象时,我的 tableview 列表中没有对象。提前致谢。

override func queryForTable() -> PFQuery {
    let query = PFUser.query()

    if searchInProgress {
        // We are looking for the string contents in the search bar to match the names in the parse username category.
        query?.whereKey("username", containsString: searchString)
    }

    // From the objects aleady loaded...
    if self.objects?.count == 0{
        // If we have not already loaded the elements from our database, then it will use the elements that have already been downloaded when we have already run the app
        query?.cachePolicy = PFCachePolicy.CacheThenNetwork
    }

    query?.orderByAscending("username")
    return query!
}

【问题讨论】:

    标签: ios swift parse-platform ios8 xcode6


    【解决方案1】:

    您不能同时使用固定和缓存策略,因此会出现不一致异常。 http://parse.com/docs/ios/api/Classes/PFQuery.html#//api/name/cachePolicy

    【讨论】:

      猜你喜欢
      • 2015-09-15
      • 1970-01-01
      • 1970-01-01
      • 2017-07-22
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      相关资源
      最近更新 更多