PDA

View Full Version : Fetching a value from the settings bundle?




Locker
Mar 9, 2009, 10:02 AM
I'm brand new to programming for the iPhone (with only PHP as previous programming experience) and have managed to put together a simple app which does calculations. I've created a settings.bundle which appears to work, but now I'd like to fetch the values from it to use in my app. My Root.plist looks like this:

<?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>Title</key>
<string>TestApp</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Set Value</string>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Value Selector</string>
<key>Key</key>
<string>Value Selector</string>
<key>DefaultValue</key>
<string>0</string>
<key>Values</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
</array>
<key>Titles</key>
<array>
<string>One Value</string>
<string>Another Value</string>
<string>A Third Value</string>
</array>
</dict>
</array>
</dict>
</plist>


I want to use the string 'One Value', 'Another Value' or 'A Third Value', depending on what has been selected.

Any help would be greatly appreciated :)



Aquis
Mar 11, 2009, 04:50 AM
[[NSUserDefaults sharedDefaults] integerForKey:@"Value Selector"];


Will return 0, 1 or 2 based on the user's preferences. There are plenty of sites which could have told you this (http://***********/?q=iphone+application+preferences)...

Locker
Mar 11, 2009, 04:58 AM
[[NSUserDefaults sharedDefaults] integerForKey:@"Value Selector"];

There are plenty of sites which could have told you this (http://***********/?q=iphone+application+preferences)...
Try as I might (and I did try...), I couldn't seem to find the simple answer I was after. Thank you.