Avatar
Avatar
omochimetaru
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)
omochimetaru 3/3/2022 11:30 AM
この自分のやつはtest1とtest2はメソッド