parsing解除locking不会从本地数据存储删除对象

这应该工作。

下面是解决这个问题的很多尝试之一

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) } } } } 

我做了一个查询后,取消固定和对象仍然存在。

我已经联系了支持团队了解无法取消固定具有引用对象的对象的问题,因此我将这些线索分享给感兴趣的人员:

https://developers.facebook.com/bugs/138298746504630/

支持人员说这是By Design,但是根据我的要求改进这个规范,他告诉我他会告诉团队的。

其中一个原因不适用于您的原因是,您的本地数据存储中可能还有与您想要解除绑定的对象有关系的对象。 要正确执行此操作,请先取消固定所有这些对象,然后取消固定目标对象。

我得到这个工作,但使用以下工作stream程。

当我创build一个新的对象,并准备保存我做了以下2个步骤

  newThing.saveEventually(nil) newThing.pinInBackgroundWithBlock { (res, errn) -> Void in // pinning is required for offline delete to work correct if errn != nil { return } //self.presentingViewController?.dismissViewControllerAnimated(true, completion: { () -> Void in // dismiss modal if required... //}) } 

在我的tableview中,我删除像这样

 override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { if editingStyle == .Delete { self.myDataSource[indexPath.row].deleteEventually() self.myDataSource.removeAtIndex(indexPath.row) self.myDataSource.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) } } 

在相同的tableview中提取进程

  1. 本地查询 – 从本地数据存储 – 这直接更新我的tableview – 首先调用
  2. networking查询 – 这是取消locking和固定,更新tableview数据源 – 完成后,再次调用本地查询更新表。

这是我的networking查询

 func networkQuery() { let nquery = theQuery() nquery.findObjectsInBackgroundWithBlock { (objects, error) -> Void in if let temp = objects as? [YourObjectType] where error == nil { PFObject.unpinAllInBackground(self.myDataSource, block: { (resultBool, error) -> Void in if error != nil { return } PFObject.pinAllInBackground(temp, block: { (resultBool, error) -> Void in if error != nil { return } self.localQuery() }) }) } } } 

我试图打破这个创build新的项目,在线和离线 – 删除和离线项目 – 所有的作品。 希望它有帮助,在网上找不到任何例子,所以只能去跟踪和错误的工作….痛苦的过程,但像现在的魅力工作。

在对parse.com进行研发之后,我发现,一旦存储在云中,就可以从本地存储中取消固定对象。 B'cozparsing基本上用于在云上存储数据,因此它允许在云上存储后解锁数据。 例如。

 - (void)syncDataToCloud:(id)sender { PFQuery *qry = [PFQuery queryWithClassName:@"Person"]; [qry fromLocalDatastore]; NSArray *arr = [qry findObjects]; [PFObject saveAllInBackground:arr block:^(BOOL succeeded, NSError *error) { if (succeeded) { DisplayAlert(@"Sync successful."); } else { DisplayAlert(@"Sync unsuccessful"); } }]; [PFObject unpinAll:arr]; } 

这个对我有用…!! 🙂