SwiftUI의 View - body는 기본적으로 @ MainActor 매크로를 채택하고 있다.

하지만 여기서 문제
body안에 내가 만든 커스텀 some View를 넣으면 어떻게 될까?
struct ExampleView: View {
var body: some View {
CustomView
}
var CustomView: some View {
Button(action: {
Task {
print(Thread.isMainThread)
}
}) {
Text("버튼입니다.")
}
}
}
내가 생각 했던 가정
MainActor 에서 CustomView 실행시키니깐 MainActor를 채택할 것이다.
정답은 ❌false 가 출력된다
About the author
안녕하세요🙇🏻♂️ 세상을 더 편리하게 바꾸고 싶은 iOS 개발자 최인호입니다.
Hello 👋 I'm Inho Choi, an iOS developer who wants to change the world more conveniently.
- 대학교 졸업
- Apple Developer Academy @ POSTECH 1기
- KWDC Main Organizer
- AsyncSwift Organizer
Comments
Join the discussionNo comments yet. Be the first to comment.