0

I'm use to have a class for several complex subviews in a view. Each can encapsulate it's own state. SwiftUI will let you refactor a long view function into subviews but I have not found anything other than passing @Binding variables through the views.

I keep ending up with a lot of state variables on the main view. Ideally what I would like would be if I could reference a subview of the main and directly set it's state like this

mainView.bottomPane.odometer.speed = 55

Is this possible? If not are there other ways around large chunks of State variables in the main form?

madmik3
  • 6,975
  • 3
  • 38
  • 60
  • This might help you: [SwiftUI - Can I share functions with an extracted subview?](https://stackoverflow.com/q/63428497/8697793) – pawello2222 Sep 13 '20 at 23:48
  • Your example code sounds as it should be in view model instead of state. But to make it clear would you provide minimal example? – Asperi Sep 14 '20 at 04:11

0 Answers0