我的代碼如下所示,而我不明白的是爲什麼Void in
之後的代碼永遠不會運行?我確實嘗試過調試,但似乎Block
從未得到執行。findObjectsInBackgroundWithBlock沒有進入「Block」
順便說一下,查詢將返回空。
let query = PFQuery(className: "LastId")
query.whereKey("UserId", equalTo: opUserIdList[i])
query.findObjectsInBackgroundWithBlock({ (objects, error) -> Void in
if let objects = objects {
for object in objects {
object.setValue(self.opLastIdChangedToList[i], forKey: "lastId")
object.saveInBackground()
}
} else {
let newLine = PFObject(className: "LastId")
newLine["lastId"] = self.opLastIdChangedToList[i]
newLine["userIdself."] = self.opUserIdList[i]
newLine.saveInBackground()
}
})
//rest of the code
提供有關這是怎麼運行更多的情況下,它怎麼知道開始 – Wain
當我調試運行查詢的代碼。 query.findObjectsInBackgroundWithBlock,然後跳轉到//代碼的其餘部分。 – ErkanA
因爲它是異步?嘗試在該塊內部放置一個斷點,並等待您的應用進入該塊。 – Larme