2

I was going through closure in swift3. I read that in closure to avoid cyclic reference we declare list of captures, like [weak self].

In objective-C we used to declare weak reference to self and use that weak reference in blocks as below:

weak SomeClass *obj = self

I want to know is there any difference between both the approaches, or its just a new way of declaration in swift.

Can I declare weak reference as below in swift3:

weak var weakSelf = self

and use weakSelf in my closure?

Nuzhat Zari
  • 3,398
  • 2
  • 24
  • 36

0 Answers0