Question

I have textFields in Settings and i am able to get the value from it. Whenever i try to get the dictionary from PSMultiValueSpecifier, its always null. Even though i make selection in settings bundle its still null, i can understand that its null util user makes a selection but it remains null all the time.

 <?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>Title</key>
        <string>Please Select Orientation</string>
        <key>Type</key>
        <string>PSGroupSpecifier</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSToggleSwitchSpecifier</string>
        <key>Title</key>
        <string>Landscape</string>
        <key>Key</key>
        <string>orientationSwitch</string>
        <key>DefaultValue</key>
        <true/>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSGroupSpecifier</string>
        <key>Title</key>
        <string>Select Board</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSTextFieldSpecifier</string>
        <key>Title</key>
        <string></string>
        <key>Key</key>
        <string>boardTextField</string>
    </dict>
    <dict>
        <key>Type</key>
        <string>PSMultiValueSpecifier</string>
        <key>Title</key>
        <string>Select Board</string>
        <key>Key</key>
        <string>boardChoice</string>
        <key>DefaultValue</key>
        <string>1</string>
        <key>Titles</key>
        <array>
            <string>Glass</string>
            <string>Welcome</string>
            <string>Mate</string>
        </array>
        <key>Values</key>
        <array>
            <string>0</string>
            <string>1</string>
            <string>2</string>
        </array>
    </dict>
</array>
<key>StringsTable</key>
<string>Root</string>
 </dict>
 </plist>

and here is how i am getting the value.

 NSDictionary *boardChoice = [defaults dictionaryForKey:@"boardChoice"];
 NSLog(@"board Choice = %@", boardChoice);

Thanks

Was it helpful?

Solution

A preference of type "PSMultiValueSpecifier" does not set a dictionary in the user defaults, but one of the possible "Values". So

NSString *boardChoice = [defaults stringForKey:@"boardChoice"];

should work and in your case should return "0", "1", or "2".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top