Avatar
omochimetaru 3/3/2022 11:08 AM
class Test { func test1(_ f: @MainActor @escaping () async -> Void) { Task.detached { await f() } } func test2(_ f: @escaping () async -> Void) { test1(f) } func main() async { let _: Void = await withUnsafeContinuation { c in test2 { print(Thread.current) c.resume(returning: ()) } } let _: Void = await withUnsafeContinuation { c in test2 { @MainActor () in print(Thread.current) c.resume(returning: ()) } } } } // AppDelegate func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { Task.detached { await Test().main() } return true } (edited)