Michael Long
Sep 15, 2024

--

Never do this...

Task { [weak self] in

guard let self else { return }

...

}

Since the task will execute almost immediately, the weak self is immediately unpacked and as such accomplishes nothing.

Task closures are not completion handlers.

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

Responses (1)