Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure previous cells' prepareForReuse doesn't affect new cells by re…
…moving the `onReuse` closure reference when releasing the cell for reuse. Every time we update the table view state, existing cells can be reused for different index paths, where they'll be managed by different cell controllers - so we need to remove all references to the previous cell controllers when releasing the cell for reuse. Since the `onReuse` closure references the cell controller via `self`, we need to set `onReuse` to `nil` when releasing the cell for reuse by another cell controller. This way, we ensure there are no references to the cell controller so there will be no side effects.
- Loading branch information