Reckoned
(Reckoned)
1
Hi do I need to have @MainActor on the function that creates the @MainActor class?
Example:
@MainActor
class Object {}
class ObjectFactory {
@MainActor func create() -> object {
.init()
}
}
Is putting @MainActor on func create correct? Is there a better way?
somu
(somu)
2
I think you making create @MainActor is better than my suggestion (below).
Or you could make create asynchronous and await on Object creation as follows:
class ObjectFactory {
func create() async -> Object {
await Object()
}
}