Reputation: 24426
If I have a plist which I have put into and array, which looks something like this
-Root
-Item 0 Dictionary
Name String Henry
Kids Array
-Item 0 String Lindy
-Item 1 String Paul
-Item 1 Dictionary
Name String Janet
Pets Array
-Item 0 String Snoopy
-Item 1 String Pebbles
How can find out whether each person has kids or pets?
Upvotes: 0
Views: 147
Reputation: 1017
You can query NSDictionary with valueForKey:key //returns nil, if valued for key is not present.
NSDictionary *person = read the person to this..
if(nil == [person valueForKey:@"Kids"])
{
//has no kids..
}
else
{
//has kids
}
if(nil == [person valueForKey:@"Pets"])
{
//has no pets..
}
else
{
//has pets
}
Upvotes: 1