How to initialize Swift class annotated @MainActor for XCTest, SwiftUI Previews, etc – Ios swift
We'd like to make use of the @MainActor Annotation for our ViewModels in an existing SwiftUI project, so we can get rid of DispatchQueue.main.async and .receive(on: RunLoop.main). @MainActor class MyViewModel: ObservableObject { private var counter: Int init(counter: Int) { self.counter…