ios7 - 删除Parse后端中的tableview对象

时间:2014-01-01 21:51:06

标签: ios uitableview parse-platform

两个问题:

如何在iOS / Parse中删除对象?

如何重新排列对象?

要删除的代码是:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
            [currentItem deleteInBackground];
        [self.tableView reloadData];

    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
    }
} 

此代码没有任何反应。没有崩溃但也没有变化。

重新排列 - 代码仅限:

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%s", __FUNCTION__);

    return YES;
}

这样可行,但不会粘住 - 下次运行时,行会按原始顺序返回。

1 个答案:

答案 0 :(得分:1)

您可以检查删除过程是否已成功完成。 请查看以下代码段

[self.currentItem deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
            if(!error){
                [self.tableView reloadData]; // if you are using normal table view

                // if you are using PFQueryTableViewController
                //[self.pfqueryTableViewController loadObjects];
            }
            else
            {
                // check error
            }
        }];