AutoTable icon indicating copy to clipboard operation
AutoTable copied to clipboard

Retain cycle on deleteClosure

Open adriencog opened this issue 8 years ago • 0 comments

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?

adriencog avatar Sep 09 '17 12:09 adriencog