I have a plist like this:
<dict>
<key>New item</key>
<dict>
<key>document</key>
<string>driving licence</string>
<key>Overview</key>
<string>a driving licence is required.......</string>
</dict>
if I want to get the object I would write something like this:
myString = [somedictionary objectForKey:@"Overview"];
what about if I want to get “overview” from my plist???
I Hope it’s clear….. Please do not give negative vote…. I’m still learning!;-)
EDITED VERSION:
Better to be more specific:
i have this code
for (NSDictionary *playDictionary in playDictionariesArray) {
Play *play = [[Play alloc] init];
play.name = [playDictionary objectForKey:@"playName"];
which is the Apple sample code:
http://developer.apple.com/library/ios/#samplecode/TableViewUpdates/Introduction/Intro.html
In this sample the string play return the name of the play in the header section but I want
to modify it and get the “Key” in the header (in this case would be “PlayName).
THANKS TO EVERYBODY: THIS IS HOW I FIXED IT:
NSMutableArray *anArray = [[NSMutableArray alloc] init];
[anArray addObject:@"Overview"];
[anArray addObject:@"pre-requirements"];
[anArray addObject:@"where"];
[anArray addObject:@"what"];
//Use a for each loop to iterate through the array
for (NSString *s in anArray) {
Play *play = [[Play alloc] init];
play.name = s;
You can get an array of all the keys in the dictionary using
[dict allKeys]. You can get an array of all keys whose value is a specific object using[dict allKeysForObject:object]. You can process the keys one-by-one in a loop like this: