How should I use a property of a type on main actor as default value of parameters?

@MainActor struct SomeView: UIViewRepresentable {
       func set(screenSize: CGSize = UIScreen.main.bounds.size) {...}

In case of that, I meet an error that says "class property 'main' isolated to global actor 'MainActor' can not be referenced from this synchronous context."
It also says the same error for 'bounds' .
Is there any way to fix this ? Xcode's version is 13.2.1


I would also like to get some guidance on this. For now I made an (ugly) workaround by also creating a global (non-class) constant.

(Explicitly declaring a static let as nonisolated does not work at the moment).

1 Like
Terms of Service

Privacy Policy

Cookie Policy