Description: SwiftUI is designed to integrate with your existing code base on any of Apple’s platforms. Learn how to adopt SwiftUI on any Apple platform by adding SwiftUI views into your app’s hierarchy, leveraging your existing data model and more.
We can host SwiftUI content in your UIKit views via a
- Lets us embed
UIViews in SwiftUI views (via
- Lets us embed child
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.
During initialization, the
make method is called first, followed by the
update method can be called multiple times, whenever an update is requested by SwiftUI.
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.
- Helps with coordinating between UIVIew/Controller and SwiftUI
- Can be used to implement common patterns, like delegation, data sources, and target action.
- Helps read SwiftUI environment
- Lets our view know if there was an animation in SwiftUI.
- 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
.onDrop), pasteboard (via