nonisolated

Generated on 10/3/2024

2 searches

In the context of Swift concurrency, the term "nonisolated" refers to a method or variable that does not have a specific isolation guarantee. This means that the method or variable can be accessed from any context, without the constraints of actor isolation.

In the session "Migrate your app to Swift 6" from WWDC 2024, it is explained that declaring a method as nonisolated means that, despite being part of a main actor isolated type, the specific method will not be isolated to the main actor. This is useful for callbacks that do not make promises about where they will be called back from. However, using nonisolated unsafe should be a last resort, as it places the burden of ensuring safety on the developer, bypassing Swift's compile-time guarantees.

For more details, you can refer to the session Migrate your app to Swift 6 (17:12).