0

Two questions:

How to delete objects in iOS/Parse?

How to rearrange objects?

Code to delete is:

- (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.
    }
} 

nothing happens with this code. No crash but also, no change.

Rearranging - code is only:

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

    return YES;
}

This works, but does not stick - next run, the rows are back in original order.

1 Answer 1

1

Can you check delete process completed successfully. check the following snippet

[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
            }
        }];
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the help. I logged the lines in the code, and there seems to be something funky going on. The app does now do the delete, but it deletes the wrong item.. I will mark this answer as correct, but I'm open to more suggestions.
Thanks again. You got me focused on the right area. It turned out that the currentItem did not have the correct index. Thank goodness for logging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.