I have severals configuration settings that I need to be able to access throughout my application. These settings can’t and won’t be editable by the user. I’m coming from a web application background and I don’t know what approach is recommended.
If my application was for the web, I would create a file config file config.py or config.php then set everything I need to set then load it where I need it. For iOS, I came across NSUserDefaults where it is use mainly for user preferences (at least that what I see people using it for). However the data I wish to store are not preferences at all.
Should I create a class and store my values in it or use NSUserDefaults ?
It is perfectly fine to use
NSUserDefaultsto store application configuration information that is not a user-visible configuration option. That said, my recommendation would be to create a class on top ofNSUserDefaultso that 1.) it is easier to change the underlying implementation if necessary and 2.) you have the strings representing the variable names only in one place (to avoid accidental spelling differences) and you can refer to individual variables by specific getter functions.