@MainActor Usage and Placement

The Realm Swift documentation mentions this repeatedly

If your app accesses Realm in an async/await context, mark the code with @MainActor to avoid threading-related crashes.

But there are no examples of where/when to use @MainActor.

Is there a best practice of how to integrate @MainActor with async/await calls? Maybe some code examples would help clarify the usage.

Jay

1 Like

Would love to see some practical examples too.