Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Locker

macrumors 6502
Original poster
Aug 22, 2007
291
0
Staffordshire, UK
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:

Code:
<?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

macrumors member
Aug 7, 2007
63
0
Staffordshire, UK
Code:
[[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...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.