Ensuring async methods do not run on the main actor

I have a manager class that updates the UI with a combine publisher. I would like to use @MainActor to make the class thread safe. It has several long running async methods that would cause responsiveness issues if run from the main actor. Is there a way to make sure those methods run in the background while the rest of the class is isolated to the main actor?

Mark them as nonisolated.

1 Like

I would recommend moving these methods to a separate actor type. This way you'd also follow separation of concerns principle, assuming you move associated state to that separate actor.