deleteRowsAtIndexPaths: swipe to delete rows never deallocates the cell?
Asked Answered
M

1

8

I'm wondering if I've somehow stumbled upon a bug where swipe to delete UITableViewCells don't ever deallocate when their UITableViewController does.

I've added a -dealloc method into my custom table cell, which logs out a message. When I press back on the navigation controller, all 6 messages are logged out.

If I swipe to delete one (or more), and press back, only 5 are logged. So I log out the pointer address of the cell that has been deleted, for future reference. Now when I go back and pause the execution at any point, I can enter into the lldb prompt:

po 140382950334240
<TableLeakCell: 0x7fe67852a490; baseClass = UITableViewCell; frame = (-375 176; 375 44); text = 'Chris'; hidden = YES; autoresize = W; gestureRecognizers = <NSArray: 0x7fe678530d70>; layer = <CALayer: 0x7fe67852a860>>

This should have been deallocated! The x.position of the cell is exactly -(tableView.width), and hidden=YES. As in the cell is still in the position after the animation has finished. Or perhaps it's being queued for reuse? Either way, it's there forever, and there's nothing in Apple's documentation about having to manually destroy a cell after calling deleteRowsAtIndexPaths.

Quick proof of concept project here: https://github.com/iOSDigital/UITableViewLeak

Muffler answered 3/12, 2015 at 0:48 Comment(1)
Nice demo. File a bug report with Apple!Rhinitis
S
0

At least using Xcode 7.2/iOS 9.2 Simulator and Xcode 7.3/iOS 9.3 Device all cells get deallocated. Only change is the order of deallocation, the deleted cell get's dealloc'd last.

Spirt answered 19/1, 2016 at 9:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.