@MainActor on function that creates the @MainActor class

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?

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()
   }
}