iosobjective-cuitableviewuitableviewrowactionsetediting

self.editing vs. self.tableView.editing and setEditing confusion


After presenting a modal view on my UITableView controller when editing is on, I found that the values of self.editing and self.tableView.editing are different when the controller is dismissed (self.editing was still on but self.tableView.editing had gone off and the tableView was in a strange state).

To correct this, I did [self setEditing:NO animated:YES] when presenting the modal view.

I've discovered that these two lines do not do the same thing:

[self.tableView setEditing:NO animated:YES];
[self setEditing:NO animated:YES];

My questions are:

(1) why is there a difference in those commands and

(2) how can the state of self.editing and self.tableView.editing be different?


Solution

  • According the documentation

    self.editing
    

    A Boolean value indicating whether the viewController currently allows the user to edit the view contents

    self.tableView.editing
    

    A Boolean value that determines whether the table view is in editing mode.

    I think you can understand by the definition it self, viewController editing refers to if the viewController allows editing.