|
I have a picker that you select a manufacturer from, the a second picker which will list the models of said manufacturer. The dimensions of the models are stored as individual dictionaries in a seperate swift file than the View file. I have an array of the dictionaries in the view file, I would like to somehow do a mathematical operation with either of the elements of the dictionary based on the model selection in the picker.
The swift file with the data is as below:
|
|
Honestly, I would start by rethinking your data model. The way you have it right now is a bit difficult to make sense of. The variable names don't really give the person reading your code much of a clue to what they will be recieving from them. Also, there is no need to have all of those published variables. From what I can tell, all of the data in your ObservedObject class is data that you would want to be constant and never manipulated by the user. So, there is no reason for them to be published, or to be variables at all. I came up with a different way of creating the data model, and honestly, I don't think it's all that great still. But, I came up with it rather quickly and didn't want to spend all day on it. Anyway, it accomplishes what you are wanting to do, and maybe it will give you some hints as to how you might accomplish your goal in an even better way. This is the new data model that I came up with. Instead of having so many published variables, it uses static let arrays of Panel I didn't fill in all of the info for all of the panel types, so you would have to do that part on your own.
I had to make some changes to your View to make it fit with the new data model. But, it is mostly the same as what you had. I also removed some Lists that were just unnecessary to have in there.
|
|
|
|
@FlyOstrich Mate, you are an absolute genius, Can't thank you enough. Please pardon my very basic skills and knowledge. |
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.