This should work.
Here is one of many attempts to get this figured out
myTrainingSessions[indexPath.row].unpinInBackgroundWithBlock{ (succ, e) -> Void in
if succ == true {
// just remove from table view etc
self.myTrainingSessions[indexPath.row].deleteEventually()
self.myTrainingSessions.removeAtIndex(indexPath.row)
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
// Shows that my object is still in datastore!
// object should be UNPINNED - but appers in this result....
var query = PFQuery(className:TrainingSession.parseClassName())
query.whereKey(self.userType(), equalTo: PFUser.currentUser())
query.orderByDescending("createdAt")
query.fromLocalDatastore().ignoreACLs()
query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if error != nil { return }
if let result = objects as? [TrainingSession] {
println("local results")
println(result)
}
}
}
}
I do a query after unpinning and the object is still there.
I've contacted the support team about the problem where you can't unpin an object that has a referenced object, so I'm sharing the thread for those interested:
https://developers.facebook.com/bugs/138298746504630/
The support person said it was By Design, but upon my request to improve this specification, he told me he would tell the team about it.
One of the reasons this is not working for you is because there might still be objects in your local datastore that have relation with the object you want to unpin. To do this properly, unpin all those objects first and then unpin the target object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With