-
I'm have possibly a weird setup, but I have an AppKit view controller to render a collection view, but the rows are rendered with SwiftUI all driven by a TCA store. I'm holding on to the store as |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Have you tried smth like this? class ParentVC: NSViewController {
@UIBindable
var store: StoreOf<Feature>
func someSetupFuncForSUIView() {
// pass store directly to content view
someHostingController.rootView = FeatureContainerView(store)
}
}
// If it's your VC's entire content view, I'd probably put it inside of `ParentVC` class and remove `Container` from naming
struct FeatureContainerView: View {
// use state in content view to get bindings from the store rather then @UIBinding
@SwiftUI.State
private var store: StoreOf<Feature>
init(_ store: StoreOf<Feature>) {
self.store = store
}
var body: some View {
// here is your binding for `property`
SomeBindableView($store.property.sending(/*send custom action if needed*/))
}
} This approach should probably work with any |
Beta Was this translation helpful? Give feedback.
-
You can also always create a local class VC: UIViewController {
@UIBindable var store: StoreOf<Feature>
func buttonTapped() {
@Bindable var store = store
$store.property // Binding<…>
}
} That's pretty similar to what one does in SwiftUI when you have an |
Beta Was this translation helpful? Give feedback.
You can also always create a local
@Bindable
store for derivingBinding
s from:That's pretty similar to what one does in SwiftUI when you have an
@Environment
model and you do@Bindable var model
in the view to then get bindings from it.