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

isaaclimdc

macrumors 6502
Original poster
Jun 28, 2009
362
0
Pittsburgh, PA
Can anyone tell me how do I extract and alloc individual values in my plist array of dictionaries to some NSString?

For example, I key in names and their emails:

Code:
<array>
	<dict>
		<key>Name</key>
		<string>John Doe</string>
		<key>Email</key>
		<string>jdoe@gmail.com</string>
	</dict>
	<dict>
		<key>Name</key>
		<string>Alex Smith</string>
		<key>Email</key>
		<string>asmith@gmail.com</string>
	</dict>
</array>

How do I display Alex Smith's email in a text label in some field?
 
Code:
NSArray* plist = [NSArray arrayWithContentsOfFile:pathToPlistFileInMyBundle];

for (NSDictionary*d in plist)
{
     NSString* name = [d objectForKey:@"Name"];
     NSString* email = [d objectForKey:@"Email"];
     // do something with the strings here
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.