iOS 앱을 만들고 있는데 UITableView에서 행을 삭제하려고합니다. 또한 Parse를 앱의 모바일 백엔드로 사용하고 있습니다. query.findObjectsInBackground는 하나의 객체를 반환해야하므로iOS Swift 3 Parse를 사용하여 TableView에서 행 삭제하기
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
let query = PFQuery(className: "Receipts")
let currReceipt = receipts[indexPath.row]
query.whereKey("objectId", equalTo: currReceipt.objectId!)
query.findObjectsInBackground(block: { (objects, error) in
if error != nil {
self.createAlert(title: "Oops! Something went wrong number 1!", message: "We could not delete the receipt")
print("THERE WAS AN ERROR DELETING THE OBJECT")
}else{
for object in objects!{
self.receipts.remove(at: indexPath.row)
object.deleteInBackground()
self.table.reloadData()
}
}
})
}
}
그냥 명확하게, 단지 주어진 "OBJECTID"로 데이터베이스에서 한 영수증이있을 것이다 : 여기 삭제 방법에 대한 코드입니다.
시뮬레이터에서 행을 삭제하려고하면 개체가 데이터베이스에 있음을 알 수 있지만 "개체를 찾을 수 없음"오류가 발생합니다. 내가 도대체 뭘 잘못하고있는 겁니까?
업데이트 오랜만에 내 솔루션을 찾았습니다. 관심있는 사람은 읽기 및 쓰기 권한의 기본 ACL 값과 관련이 있습니다. 답변에 대한 링크는 다음과 같습니다. Parse weird bug in Swift that causes ACL write permissions to change to an objectId
"!" 나는 "Expression이 [String]에서 암묵적으로 강요 당했다는 경고를 받는다. to any " –
수일 간의 검색 후 내 솔루션을 찾았습니다. 관심이있는 경우 : http://stackoverflow.com/questions/34926827/parse-weird-bug-in-swift-that-causes-acl-write -permissions-to-an-objec –