[safe self] in

If this is occurring often in your code, I think you're probably doing something wrong (?)

Use the implicit (strong) self for completion handlers, animation blocks, network request callbacks, alert button tap handlers, background queue dispatch, and almost everything else where the closure is guaranteed to be called exactly once (or where the closure is guaranteed to be released, such as for alert button handlers).

The only real reason you'd need the weak-strong dance is for event handlers, notification observers, signal handlers, and other such cases where the closure is registered in some storage, and then called any number of times, until explicitly de-registered.

And when you really need it, it is probably a good idea a reason about retain cycles and be explicit about your choices. Just implicitly returning is probably a bad idea, even for void-closures.

4 Likes