Assessing elements in plist iphone sdk

Posted by quky on Stack Overflow See other posts from Stack Overflow or by quky
Published on 2009-12-19T17:31:31Z Indexed on 2010/04/03 11:03 UTC
Read the original article Hit count: 440

Filed under:
|

ok i have a plist like this

`
<dict>
<key>Rows</key>
<array>
	<dict>
		<key>WireSize</key>
		<string>16 AWG</string>
		<key>Children</key>
		<array>
			<dict>
				<key>Cooper 60°C (140°F)</key>
				<string>0</string>
			</dict>
			<dict>
				<key>Cooper 75°C (167°F)</key>
				<string>0</string>
			</dict>
			<dict>
				<key>Cooper 90°C (194°F)</key>
				<string>14</string>
			</dict>
			<dict>
				<key>Aluminum 60°C (140°F)</key>
				<string>0</string>
			</dict>
			<dict>
				<key>Aluminum 75°C (167°F)</key>
				<string>0</string>
			</dict>
			<dict>
				<key>Aluminum 90°C (194°F)</key>
				<string>0</string>
			</dict>
		</array>
	</dict>
	<dict>
		<key>WireSize</key>
		<string>16 AWG</string>
		<key>Children</key>
		<array>
			<dict>
				<key>Cooper 60°C (140°F)</key>
				<string>0</string>
			</dict>
			<dict>
				<key>Cooper 75°C (167°F)</key>
				<string>0</string>
			</dict>
			<dict>
				<key>Cooper 90°C (194°F)</key>
				<string>14</string>
			</dict>
			<dict>
				<key>Aluminum 60°C (140°F)</key>
				<string>0</string>
			</dict>
			<dict>
				<key>Aluminum 75°C (167°F)</key>
				<string>0</string>
			</dict>
			<dict>
				<key>Aluminum 90°C (194°F)</key>
				<string>0</string>
			</dict>
		</array>
	</dict>

</array>

`

and been trying to read the values from it but not success

i am using this code

enter NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath = [bundle pathForResource:@"Table 310-16" ofType:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath];

for (id key in dictionary) {
	NSArray *array = [dictionary objectForKey:key];
	NSLog(@"key: %@, value: %@", key, [array objectAtIndex:0]);
} here

and the results are

key: Rows, value: {
Children =     (
            {
        "Cooper 60\U00b0C (140\U00b0F)" = 0;
    },
            {
        "Cooper 75\U00b0C (167\U00b0F)" = 0;
    },
            {
        "Cooper 90\U00b0C (194\U00b0F)" = 14;
    },
            {
        "Aluminum 60\U00b0C (140\U00b0F)" = 0;
    },
            {
        "Aluminum 75\U00b0C (167\U00b0F)" = 0;
    },
            {
        "Aluminum 90\U00b0C (194\U00b0F)" = 0;
    }
);
WireSize = "16 AWG";

}

but still don't know how to get and specific value for example Aluminum 60°C (140°F) or 14 or 16 AWG any help would be appresiated

HP

© Stack Overflow or respective owner

Related posts about plist

Related posts about iphone