當我取消檢查表格行時,我想從Parse中刪除一個對象。如何從Parse中刪除對象?
嘗試從Parse中刪除對象後,查詢它們時會發生此問題。
這是我的代碼:
if cell.accessoryType == UITableViewCellAccessoryType.Checkmark {
cell.accessoryType = UITableViewCellAccessoryType.None
var query = PFQuery(className:"Followers")
query.whereKey("follower", equalTo: "\(PFUser.currentUser()?.username)")
query.whereKey("following", equalTo: "\(cell.textLabel?.text)")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
for object in objects as! [PFUser] {
object.deleteInBackground()
}
} else {
println(error)
}
}
}
你可以使用Xcode中放置一個斷點,看看'deleteInBackground'被調用? – kezi
我檢查了println,它沒有被調用... – lapacino
你可以檢查'objects.count!= 0'嗎?或者你能看到什麼叫做? – kezi