3

I used to write stuff like this before Swift 5.7:

// random async completion block    
{ [weak self] in
    guard let weakSelf = self else { return }
    weakSelf.someString = ""
}

Now I would prefer writing this:

// random async completion block    
{ [weak self] in
    guard let self else { return }
    self.someString = ""
}

But can I do this without any issue, like retain cycles?

Thank you

1 Answers1

1

Yes it's, because the guard let self else & guard let weakSelf = self is the same thing

To avoid the retain cycle you are using weak, that's other thing

Jirson Tavera
  • 1,303
  • 14
  • 18