15

I am facing a issue with App settings, i am using settings bundle to select the environment, but once selected and going back to app settings its showing again the default one as selected.

This is observed only from ios 8.2 and above(Device and simulator). My settings bundle plist looks like below.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>PreferenceSpecifiers</key>
    <array>
        <dict>
            <key>DefaultValue</key>
            <string>1</string>
            <key>Key</key>
            <string>Environment</string>
            <key>Title</key>
            <string>Environment</string>
            <key>Titles</key>
            <array>
                <string>Live</string>
                <string>Stage</string>
            </array>
            <key>Type</key>
            <string>PSRadioGroupSpecifier</string>
            <key>Values</key>
            <array>
                <string>0</string>
                <string>1</string>
            </array>
        </dict>
    </array>
    <key>StringsTable</key>
    <string>Root</string>
</dict>
</plist>

I already see some info in Stack overflow that this is existing bug from Apple, I hope if some one has any any update on it.

Vaibhav Mule
  • 5,016
  • 4
  • 35
  • 52
Linux world
  • 3,750
  • 11
  • 44
  • 59
  • may be these could help you - 1. http://stackoverflow.com/questions/29163955/ios-8-2-settings-bundle-default-value 2.http://stackoverflow.com/questions/29155410/ios-8-2-nsuserdefaults-standarduserdefaults-returning-nil?rq=1 3.http://stackoverflow.com/questions/14077431/register-default-settings-from-the-settings-bundle-plist-file?rq=1 4.http://www.codedisqus.com/0SNjqXVqee/ios-settingsbundle-localization-difficulties.html – Ankit Kumar Jun 01 '15 at 06:30
  • 2
    I encountered the same thing but only when using a PSRadioGroupSpecifier, aka a Radio Group Element as Apple calls it here: https://developer.apple.com/library/ios/documentation/PreferenceSettings/Conceptual/SettingsApplicationSchemaReference/Articles/RadioGroupElement.html Since XCode's plist editor does not recognize this type, I think Apple did not really implement this completely. So I used a Multi Value Element (PSMultiValueSpecifier) instead, which is basically the same thing except with the values in a separate screen. – hotdogsoup.nl Jun 02 '15 at 13:06

2 Answers2

1

If your apperance settings are set during launch, you must reload your app viewcontrollers to display the change, so you could add to your appDelegate something like:

NSString *type in your ivars

then

type = [[NSUserDefaults standardUserDefault] objectForKey:@"Your key"];

in your didFinishLaunchingWithOptions: method

and finally, in your didEnterForeground method, add

if(![[[NSUserDefaults standardUserDefault] objectForKey:@"Your key"] isEqualToString:type]){
  //Reload your main view controller
  [self.window.rootViewController viewDidLoad]; 
  [self.window.rootViewController viewWillAppear:YES];
} 
AdminXVII
  • 1,319
  • 11
  • 22
0

There appears to be a bug in iOS 8 and up where Radio Button settings always revert to the default value in the settings app. Others are running into the same issue: iOS settings bundle PSRadioGroupSpecifier does not show selected value

Community
  • 1
  • 1
Cogwheel
  • 22,781
  • 4
  • 49
  • 67