繁体   English   中英

解析本地数据存储区:Swift中的Unpin对象似乎已被破坏

[英]Parse Local Datastore: Unpin objects seems broken in Swift

我想取消一个对象列表,我已经成功地在本地存储了它,并用一个新对象替换它。 下面的代码应该这样做,但本地固定的对象根本不会更新。 我尝试了包括PFObject.unpin在内的所有内容,除了完全重置模拟器外,没有任何东西会删除旧的固定对象

func updateCountryList(server:Int, local:Int) {
    let query = VEPCountry.queryAll()
    query.findObjectsInBackgroundWithBlock {
        (objects: [AnyObject]!, error: NSError!) -> Void in
        if error != nil {
            // throw error
        } else {
            if local != 0 {
                VEPState.unpinAllObjectsWithName(String("countryListVersion\(local)"))
            }
            VEPState.pinAll(objects, withName: String("countryListVersion\(server)"))
            defaults.setObject(server, forKey: "localCountryListVersion")
        }
    }
}

感谢帮助或指向Swift中的unpinning周围的已知问题

我想知道你的unpin是否真的没有完成,毕竟它会进入数据库。

你能试一下吗:

query
  .findObjectsInBackground()
  .continueWithSuccessBlock({ (task: BFTask!) -> AnyObject! in
    // ...
    return VEPState.unpinAllObjectsWithNameInBackground("name"))
  })
  .continueWithSuccessBlock({ (task: BFTask!) -> AnyObject! in
    // ...
    return VEPState.pinAllInBackground(objects, withName: "name"))
  })

我可能有一点关闭语法,背景方法名称不太正确。 我也在使用承诺/任务,这不是一个坏习惯。

暂无
暂无

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

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