Matthew Hui
Matthew Hui

Reputation: 3361

Leaving swipe to delete button open on uitableview cell then going back causes crash

I have swipe to delete on one of my table cells. If I swipe right on the table cell to display the delete button and pop the view by pressing the back button the app crashes with Thread 1: EXC_BAD_ACCESS. I've already singled this out as the reason it crashes. Why does this happen?

This is what it looks like when I tap back https://www.dropbox.com/s/ggn4jqr0ox0tnta/Screenshot%202014-12-04%2023.39.25.png?dl=0

Upvotes: 6

Views: 898

Answers (4)

pcholberg
pcholberg

Reputation: 520

This caused because delegate and datasource of the table is simple assign pointer, not weak. So after deleting view controller, containing table still can send events to the controller. To avoid this you can manually set tableview delegate and datasouce to nil in dealloc method. BTW, this happens not only with tables.

Upvotes: 0

Apsara
Apsara

Reputation: 61

When you are swiping right, may be you are popping the controller. Because the view is disappearing, you have to write NANNAV's lines.

Upvotes: 0

NANNAV
NANNAV

Reputation: 4901

Set UITableview end editing to NO in viewWillDisappear

[tableview setEditing:NO];

Upvotes: 12

Sudhir
Sudhir

Reputation: 75

Where you remove your cell from table view. You also have to delete data from you array.

Upvotes: 0

Related Questions