| UIHostingController | UIViewControllerRepresentable | UIViewRepresentable | 
|---|---|---|
| UIKit에서 SwiftUI 뷰를 사용 | SwiftUI에서 UIViewController을 사용 | SwiftUI에서 UIView를 사용 | 
class UIHostingController<Content> where Content : View
UIKit의 view controller에서 SwiftUI의 뷰 계층을 관리할 수 있도록 하는 컨트롤러
SwiftUI 뷰를 UIKit의 뷰 계층에 통합하고 싶을 때 UIHostingController을 사용한다.
rootView에 SwiftUI 뷰를 지정rootView 프로퍼티를 통해 뷰를 변경 가능protocol UIViewControllerRepresentable : View where Self.Body == Never
UIKit 뷰 컨트롤러를 나타내는 뷰
SwiftUI에서 UIViewController를 생성하고 관리하기 위해 UIViewControllerRepresentable의 인스턴스를 사용
앱의 커스텀 인스턴스 중 하나에 프로토콜을 적용하고, 이를 사용하여 뷰 컨트롤러를 생성, 업데이트 및 해체(tear down)
시스템은 뷰 컨트롤러에서 발생하는 변경사항을 SwiftUI의 다른 부분에 자동으로 전달하지 않음
associatedtype UIViewControllerType: UIViewControllerfunc makeUIViewController(context:) -> Self.UIViewControllerTypefunc updateUIViewController(:context:)func makeCoordinator() -> Self.Coordinatorprotocol UIViewRepresentable : View where Self.Body == Never
SwiftUI 뷰 계층에 UIKit 뷰를 통합하기 위한 래퍼 프로토콜
SwiftUI 인터페이스에서 UIView 객체를 생성하고 관리하기 위해 UIViewRepresentable의 인스턴스를 사용
이하 내용은 UIViewControllerRepresentable과 비슷