Normally, you can just do _ = c
, but there's also a problem that you need to ensure that c
is still alive by the completion event.
If you're not reading from c
, the compiler can assume that c
isn't being used, and optimize it out. That'd be bad since you're retaining c
to maintain the publisher subscription.
Use withExtendedLifetime
on the last access to ensure that c
is still alive by then. That last access should be in the completion
block.
Could be either:
c = withExtendedLifetime(c) { nil }
// or
withExtendedLifetime(c) {}
c = nil