I am using in my app ToggleSwitch in app settings. My settings are in plist file.
Toggle Switch Elements are these:
Type (required) = Toggle Switch
Title (required, localizable) = MyToggle
Key (required) = enabled_preference
DefaultValue (required) = (BOOL) YES;
Value for ON = (BOOL) YES
Value for OFF = (BOOL) NO
In app i do this to recognize:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL enabled = [defaults boolForKey:@"enabled_preference"];
NSLog(@"enabled = %i",enabled);
But when i first install app Toggle Switch is ON, but enabled = false. I can’t understand why ?
Also maybe some could help how to do localization in that settings plist file ?
This is because upon first launch your settings in settings bundle are not loaded to NSUserDefaults yet. You have to write a method to set your default values and register them with
registerDefaults, and add it intoapplication:didFinishLaunchingWithOptions:or any other method that gets executed on every launch.