簡體   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