Wrapping UIViewControllers in SwiftUI Views - Example #1770
Replies: 1 comment
-
Thanks for this example! I have a very complicated UIViewController and currently trying to use a TCA "shell" around it (sample repo here). I can't understand if it's possible to call one of the UIViewController's functions from a TCA action, and what's even worse, use a dependency inside that function's callback. For example, my view controller has a function like this:
and on the SwiftUI side I'd like to do something like this:
From which part of the SwiftUI code should I be calling And more importantly, how could I use a dependency's result in that callback? |
Beta Was this translation helpful? Give feedback.
-
This was an old (3 years!) discussion on the swift forums that I came across wanting to make an address picker in my app. I posted my reply there with my solution, but thought it'd be useful here as well, since many 1st part APIs are still built with delegate callbacks and their own pickers.
Here's my "Contact Picker" that allows for selection of a single address for a contact and links back to a parent reducer with a binding of the value. My parent reducer hooks into the binding action for this property and applies the selected value into form fields I have available. The picker could be easily changed to select multiple properties or one or more contacts. The last registered delegate callback is the one this API uses as the method to use. Hope this helps someone else!
Beta Was this translation helpful? Give feedback.
All reactions