How to access Settings.bundle values in Swift

183 views Asked by At

All of the examples and references for using values from Settings.bundle are presented in Objective-C and use older code no longer in use it seems.

Question

How can you read a settings value from Settings.bundle in Swift?

Example Setting (App: SomeAppForExample)

**Current Attempt (not working

The User has gone into the 'Settings' App and accessed the settings for 'SomeAppForExample', changing the value of 'Favorite Food' to "Pizza".

Example Task

How can you read the value of 'Favorite Food' in Swift, and print "Pizza" to the console?

Current Attempt (not working)

    let settingVal : String? = UserDefaults.standard.string(forKey: "someID_food");

    print(settingVal);

enter image description here

0

There are 0 answers