Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Configuration file instead of using ifdef statements to control the way the app works #354
I'm currently cleaning up the code, and I'm tempted to get rid of the ifdef statements to control the way the app works.
They are spreaded all over the place, making it hard for people to make adjustments to the app.
I'm very tempted to change this into a config file (e.g. settings.plist which is part of the app bundle) that is then evaluated during runtime to determine how the app should work. This way, by changing the settings file, you can change it from a single-issue to a newsstand app.
What's everybody's opinion on this?
Can we just set defaults in the user defaults and then allow those to be
On Tue, Nov 4, 2014 at 5:49 AM, Miguel Cornejo firstname.lastname@example.org
Can't we use
With a custom file - then we don't need to add any additional stuff to
On Tue, Nov 4, 2014 at 10:05 AM, Pieter Claerhout email@example.com
I don't think using registerDefaults is a good idea for this. If you start changing settings and already had the app installed, you would need to flush them out before you can use the new values.
I'm thinking about creating a singleton that reads in the plist file during it's initialization and assign the properties to member variables. These can be read only as they don't need to be changed during runtime anyway.
This has the advantage that rebuilding the app immediately picks up the new values.
You can then even do tricks like building the app once, updating the plist and resign to change the way the app works.
The registerDefaults are cleared each run - from the docs
The contents of the registration domain are not written to disk; you need
So as I understand it - we get the same benefit without having to write the
On Tue, Nov 4, 2014 at 10:51 AM, Pieter Claerhout firstname.lastname@example.org
Not sure I'm following you Pieter - can't we just set the defaults in the
On Tue, Nov 4, 2014 at 11:26 AM, Pieter Claerhout email@example.com