2012-12-10 2 views
0

나는 Flickr 사진을 대표하는 NSDictionary를 가지고있다.중첩 된 objectForKey 호출은 작동하지만 해당하는 valueForKey 호출은 작동하지 않습니까?

사진의 설명은 다음과 같이 다음과 같습니다

{ 
    accuracy = 16; 
    context = 0; 
    dateupload = 1355106635; 
    description =  { 
     "_content" = "Barclays Center Arena\nAtlantic Yards\nProspect Heights\nBrooklyn, New York"; 
    }; 
    farm = 9; 
    "geo_is_contact" = 0; 
    "geo_is_family" = 0; 
    "geo_is_friend" = 0; 
    "geo_is_public" = 1; 
    id = 8260097924; 
    isfamily = 0; 
    isfriend = 0; 
    ispublic = 1; 
    latitude = "40.681786"; 
    longitude = "-73.972545"; 
    originalformat = jpg; 
    originalsecret = cd1bdd846a; 
    owner = "[email protected]"; 
    ownername = atlanticyardswebcam02; 
    "place_id" = "uUNC_q9TWr1vROR4wA"; 
    secret = 320e308baa; 
    server = 8502; 
    tags = "newyork brooklyn construction prospectheights atlanticyards forestcityratner block1129 barclayscenterarena"; 
    title = "Barclays Center Arena - 20121209_2128"; 
    woeid = 28751452; 
} 

내가 중첩 된 objectForKey 통화를 통해 설명을 볼 수 있다면, 그것은 작동합니다. 즉, 다음과 같이 : 어설픈 그리고 나의 이해는이 또한해야 일이다

NSString *photoDescription = [[photo objectForKey:@"description"] objectForKey:@"_content"]; 

:

NSString *photoDescription_kv = [photo valueForKey:@"description._content"]; 

그러나, valueForKey는 항상 null를 돌려줍니다.

내가 뭘 잘못하고 있니?

답변

5

대신 valueForKeyPath를 사용해야합니다.

NSString *photoDescription_kv = [photo valueForKeyPath:@"description._content"]; 
관련 문제