Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Mac OS X Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-19-2010, 08:32 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 2
Default Accessing sub-keys of a .plist?

Right, so, talking iPhone settings now..
You have your usual way of accessing plist keys, like this:

Code:
		<dict>
			<key>cell</key>
			<string>PSSwitchCell</string>
			<key>defaults</key>
			<string>xxx.xxx.xxx</string>
			<key>default</key>
			<true/>
			<key>label</key>
			<string>WHATEVER</string>
			<key>key</key>
			<string>xxxKEYxxx</string>
			<key>PostNotification</key>
			<string>xxx</string>
		</dict>
What if the key you need to access (in the plist) is a sub-key? Like this:

Code:
<dict>
	<key>xxxKEYxxx</key>
	<dict>
		<key>xxxSUBKEYxxx</key>
		<string>xxx</string>
	</dict>
<dict>
How do you access that from your settings plist?
I should mention i'm not able to do this programmatically.
Darlo770 is offline   Reply With Quote
Old 09-07-2010, 04:50 PM   #2 (permalink)
void*
 
Join Date: Jan 2010
Location: europe
Posts: 23
Default

Load your plist into a NSDictionary and access the elements.

Code:
NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile: @"list.plist"];
        
NSDictionary *subDict = [plistDict objectForKey: @"xxxKEYxxx"];
NSString *xxxString = [subDict objectForKey @"xxxSUBKEYxxx"];

[plistDict release];
__________________
-== Indy Mac Dev ==-
voidzone is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 348
20 members and 328 guests
ADY, Alsahir, Dani77, e2applets, JasonR, keeshux, linkmx, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:28 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0