You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Foundation
import Factory
import Combine
@MainActor // Removing this fixes the error, but I need this
class HomeViewModel: ObservableObject {
@Injected(\.cardImageUrlRepository) private var cardImageUrlRepository
@Published private(set) var cardImageUrls: [String] = []
init() {
fetchCreditCardImageUrls()
}
private func fetchCreditCardImageUrls() {
Task {
// Fetch data using repository
// Set cardImageUrls to fetched data
}
}
}
Is it possible to keep the @MainActor tag?
The text was updated successfully, but these errors were encountered:
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 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?The text was updated successfully, but these errors were encountered: