Do you have to use an UnsafeContinuation when calling from asynchronous code?

Apple's documentation says: " A continuation is an opaque representation of program state. To create a continuation in asynchronous code, call the withUnsafeContinuation(function:_:) or withUnsafeThrowingContinuation(function:_:) function." here: CheckedContinuation | Apple Developer Documentation. I assume this means that it's not safe to use CheckedContinuation from async code.

Is this still applicable (even on other platforms) or is the advice outdated/wrong? It seems that other sources don't mention this at all.

This looks like a copy-paste typo to me. The exact same documentation appears for UnsafeContinuation.

More to the point, I don’t think you can create either of these without being in async code

7 Likes