I have a viewController with a UITableView
, the rows of which I allow to edit (delete) with a swipe - much like in the Mail app. I do it with, among other, this method:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
However, if I have a delete button revealed, and at the same time I use back navigation of my UINavigationController
, i.e. when I popViewControllerAnimated:
, the app crashes with the following message:
[ViewController tableView:canEditRowAtIndexPath:]: message sent to deallocated instance 0xaae64d0
How can I resolve this problem?
In your view controller's dealloc
method, set the table view's editing
property to NO
.
I had the same problem, but I was using ARC and I didn't want to be mucking about in the dealloc method. Doing it in viewWillDisappear was sufficient to stop the crash.
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[table setEditing:NO];
}
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