Home > Software engineering >  Are extensions of @MainActor classes on the main actor?
Are extensions of @MainActor classes on the main actor?

Time:02-01

If a class is on @MainActor:

@MainActor class MyClass : NSObject
{
}

does this put all its extensions on @MainActor as well?

extension MyClass
{
}

CodePudding user response:

Yes. As SE-0316 - Global actors says:

A type declared with a global actor attribute propagates the attribute to all methods, properties, subscripts, and extensions of the type by default.

  • Related