How to remove strong reference cycle from closure from method?

前端 未结 1 1539
不知归路
不知归路 2020-12-04 02:58

Here I have some examples for closure strong reference cycles. If I assign a closure to a stored property, I can use a closure capture list to make the captured reference un

相关标签:
1条回答
  • 2020-12-04 03:17

    self.method is just a syntactic sugar for creating a closure (with the default capture mode, which is strong): { () in self.method() }. If you want to use an explicit capture list, don't use the syntactic sugar -- create a closure (which is what it does anyway) explicitly:

    { [unowned self] () in self.method() }
    
    0 讨论(0)
提交回复
热议问题