I'm going to try and break this down in as simple terms as possible.
Let's say I have a Struct with this property in it
@State private var selectedGifName: String?
When a user taps an item on the screen, this property updates with a simple string containing the file name of a gif image.
Now, I have a Class in a different file of my app that makes a POST request to an API. One of the parameters of that POST request takes the gif image name contained in that State variable from the other file's Struct.
What is the most appropriate way to pass the value of selectedGifName
from my Struct, into the other file's Class where the POST request is being done.
I've tried:
-Calling the Struct directly as a new variable inside the Class, but I'm required to include parameters for every property of that Struct which isn't necessary.
-Messed with @StateObject
assignements but this doesn't work when a Struct has something a Class wants.
The connections between View files and ViewControllers is making my brain hurt. That's mainly what this comes down to. When structuring a good MVVM app, I'm really having problems understanding how different Structs and Classes can pass details about properties to one another.