AutoTable
AutoTable copied to clipboard
Retain cycle on deleteClosure
I love your declarative API approach. I had a similar one on larger scale but noticed many retain cycles with due to closures. In fact, in your example, you created a retain cycle on the deleteClosure too.
self.tableViewRenderer.tableViewModel = tableViewModelForUserList(
users,
deleteClosure: deleteUser
)
Changing the closure to the following fixed it:
self.tableViewRenderer.tableViewModel = tableViewModelForUserList(
users,
deleteClosure: { [unowned self] indexPath in
self.deleteUser(indexPath)
})
However, passing closures this way is less convenient but I couldn't find another way to solve retain cycles. Any idea of how this could be improved?