|
I am making a command line app that loads a JSON config file in which the user can specify various settings; my app crunches a ton of data and saves several image and data files as the end result. I'd like to refine the app such that the user can specify which files they want creating. A simple way to do this would be to have a "flag" in the JSON, one for each option, example might look like as follows ... NB: Code copied from a Playground for brevity.
My
... reading the config is simply ...
So this works, but I'd like to improve how I use the options in code to use the What I want in my code is ...
To read this in from my JSON config file, this becomes ...
Again, this works and with What I would like to have as the user-facing json config file would be something like ...
I'm sure this is possible by using |
|
|
|
Doing some further research, I have found a solution for decoding my JSON config file and to create my OptionSet. My solution is based on this article by Christian Tietze. By creating an
For my specific purpose, I only need to decode the JSON file. However, if I change the Not necessary for my specific case but for completeness, it would be good to get some assistance on how to do that. |
|
@roosterboy Thanks. That's the same article that I found - I should have quoted it in my own follow-up post (I'll edit and do that). |
|
After a little more research and posting the question on another forum, I did get an answer to my question. The
|
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
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.