We can host SwiftUI content in your UIKit views via a UIHostingController.
Representable Protocol
Lets us embed
UIViews in SwiftUI views (viaUIViewRepresentable)Lets us embed child
ViewControllers (viaUIViewControllerRepresentable)
The protocol has three methods:
Make: where we create the view or view controller that we want to present in SwiftUI.Update: where we update this view/ or view controller to the current configuration.Dismantle: optional.
During initialization, the make method is called first, followed by the update method.
The update method can be called multiple times, whenever an update is requested by SwiftUI.
Representable Context
Used for advanced integration: perhaps we want to expose target action or delegation in SwiftUI, or we may want to read from the environment of SwiftUI and respond accordingly.
Coordinator
Helps with coordinating between UIVIew/Controller and SwiftUI
Can be used to implement common patterns, like delegation, data sources, and target action.
Environment
Helps read SwiftUI environment
Transaction
Lets our view know if there was an animation in SwiftUI.
Item Providers
Item providers are a great technology that’s provided by
Foundation, which provides us a means of moving data around your application in various forms.It’s also a tool that we use to help transfer data across processes.
We can use them to integrate with system services like drag and drop (by using
.onDragand.onDrop), pasteboard (via.onPasteCommand)
