Swift/@MainActor
#Swift
/icons/hr.icon
付与したクラスでの処理はメインスレッドで行われる、という理解で、それが正しいのかを確認する
その理解で良さそう
基礎の考えとして、
UI系の処理はメインスレッドで行わせ、
重い処理はメインスレッドとは別のスレッドで行わせる
code:swift
@MainActor func hoge() {}
await hoge()
UIViewControllerも@MainActorが付与されている
UIViewController | Apple Developer Documentation
参考
MainActor | Apple Developer Documentation
Protect mutable state with Swift actors - WWDC21 - Videos - Apple Developer