what is nonisolated?
Asked on 06/17/2025
1 search
In the context of Swift concurrency, "nonisolated" refers to a method or type that does not have any specific actor isolation. This means that the method or type can be called from any thread without being tied to a specific actor, such as the main actor.
For example, in the session "Migrate your app to Swift 6," 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 any promises about where they will be called back from (Migrate your app to Swift 6).
Additionally, nonisolated code is flexible because it can be called from anywhere, whether from the main actor or a background thread, making it a great default for general-purpose libraries (Embracing Swift concurrency).
In summary, nonisolated allows for more flexible and general-purpose code that can be executed in various contexts without being tied to a specific actor's thread.

Migrate your app to Swift 6
Experience Swift 6 migration in action as we update an existing sample app. Learn how to migrate incrementally, module by module, and how the compiler helps you identify code that’s at risk of data races. Discover different techniques for ensuring clear isolation boundaries and eliminating concurrent access to shared mutable state.

Embracing Swift concurrency
Join us to learn the core Swift concurrency concepts. Concurrency helps you improve app responsiveness and performance, and Swift is designed to make asynchronous and concurrent code easier to write correctly. We’ll cover the steps you need to take an app through from single-threaded to concurrent. We’ll also help you determine how and when to make the best use of Swift concurrency features – whether it’s making your code more asynchronous, moving it to the background, or sharing data across concurrent tasks.

Code-along: Elevate an app with Swift concurrency
Learn how to optimize your app’s user experience with Swift concurrency as we update an existing sample app. We’ll start with a main-actor app, then gradually introduce asynchronous code as we need to. We’ll use tasks to optimize code running on the main actor, and discover how to parallelize code by offloading work to the background. We’ll explore what data-race safety provides, and work through interpreting and fixing data-race safety errors. Finally, we’ll show how you can make the most out of structured concurrency in the context of an app.