Closed cabyambo closed 1 year ago
If you mark the entire class that way then you need to mark the initializer as nonisolated in order to get around that particular problem. Marking the entire class with MainActor marks every function and method within the class as MainActor, including the initializer.
I tend to prefer marking async functions as MainActor as needed, and not the entire class. I wrote a lot about that on Medium: https://betterprogramming.pub/async-await-and-mainactor-strategies-cc35b6c58b52
I am getting an error when trying to register an
ObservableObject
marked with@MainActor
Here's how I am registering the object:
And here is the object itself:
Is it possible to keep the
@MainActor
tag?