2010-06-10 4 views
0

나는이물체가 plist 안에 존재하는지 알아 내시겠습니까?

-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 

같은 것을 보이는 나는에 넣어 가지고 PLIST 및 배열이있는 경우 어떻게 각 사람이 아이들이나 애완 동물이 있는지 여부를 알 수 있나요?

답변

1

valueForKey를 사용하여 NSDictionary를 쿼리 할 수 ​​있습니다. key // key의 값이없는 경우 nil을 반환합니다.

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 
} 
관련 문제