I have a class MyUIClass
that is @MainActor
isolated:
@MainActor
class MyUIClass {
func show(object: Any?) {}
}
To use the show
function, it needs to be accessed within the MainActor
context:
class Santa {
@MainActor
func present1(gift: Any?) {
MyUIClass().show(object: gift) // ✅
}
func present2(gift: Any?) {
Task { @MainActor in
MyUIClass().show(object: gift) //