the.bay.news

Is `[weak self]` actually necessary in a `Task` closure?

Swift Forums
Is `[weak self]` actually necessary in a `Task` closure?
I keep running into the same review comment on team PRs: "add [weak self] to that Task." Sometimes I agree, most of the time I don't, and I've never been able to point at a rule that settles it. I'd like to check my mental model against people who actually know the runtime. What I think is true Task { } takes an @escaping closure, so self is captured strongly — no argument there. But unlike a closure stored as a property, the capture is temporary: once the task's body finishes, the async fram...

I keep running into the same review comment on team PRs: "add [weak self] to that Task." Sometimes I agree, most of the time I don't, and I've never been able to point at a rule…

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.