2012-02-09 2 views
0

이 NSDictionary가 있습니다.사전을 객체로 사용하여 NSDictionary 객체 가져 오기

PhotoData =  { 
    1 =   { 
     "jf_photo_geotag" = "arayat philippines"; 
     "jf_photo_id" = 1; 
     "jf_photo_url" = "http://adomainname/iphone_images/large/jf_largeimage1.png"; 
     "jf_user_id" = 1; 
     comments =    { 
      1 =     { 
       "jf_photo_comment" = "well i like this one. really. comment from janus"; 
       "jf_photo_comment_id" = 1; 
       "jf_photo_id" = 1; 
       "jf_user_id" = 1; 
       "jf_username" = janus; 
      }; 
      4 =     { 
       "jf_photo_comment" = asasfa; 
       "jf_photo_comment_id" = 4; 
       "jf_photo_id" = 1; 
       "jf_user_id" = 1; 
       "jf_username" = janus; 
      }; 
     }; 
     likes =    { 
      2 =     { 
       "jf_like_id" = 2; 
       "jf_photo_id" = 1; 
       "jf_user_id" = 1; 
       "jf_username" = janus; 
      }; 
     }; 
     "post_date" = "2012-02-23 16:34:14"; 
    }; 
    2 =   { 
     "jf_photo_geotag" = "magalang philippines"; 
     "jf_photo_id" = 2; 
     "jf_photo_url" = "http://adomainname/iphone_images/large/jf_largeimage2.png"; 
     "jf_user_id" = 2; 
     comments =    { 
      2 =     { 
       "jf_photo_comment" = "well this is now a comment from loaclhost! for phot number 2"; 
       "jf_photo_comment_id" = 2; 
       "jf_photo_id" = 2; 
       "jf_user_id" = 2; 
       "jf_username" = fidel; 
      }; 
      3 =     { 
       "jf_photo_comment" = asdfadf; 
       "jf_photo_comment_id" = 3; 
       "jf_photo_id" = 2; 
       "jf_user_id" = 2; 
       "jf_username" = fidel; 
      }; 
     }; 
     likes =    { 
      1 =     { 
       "jf_like_id" = 1; 
       "jf_photo_id" = 2; 
       "jf_user_id" = 1; 
       "jf_username" = janus; 
      }; 
     }; 
     "post_date" = "2012-02-23 16:34:31"; 
    }; 
    3 =   { 
     "jf_photo_geotag" = "san fdo philippines"; 
     "jf_photo_id" = 3; 
     "jf_photo_url" = "http://adomainname/iphone_images/large/jf_largeimage1.png"; 
     "jf_user_id" = 3; 
     comments =    (
     ); 
     likes =    (
     ); 
     "post_date" = "2012-02-24 16:34:47"; 
    }; 
    }; 
success = 1; 

} 기본적으로

이있는 NSDictionary 등 jf_photo_id jf_photo_url, 같은 일부 문자열 데이터를 포함하고 또한 주석 등의 객체로 다른 사전을 가지고 =() 나는이 작업을 할 수있는 방법

PhotoData =  { 
    { 
     "jf_photo_geotag" = "arayat philippines"; 
     "jf_photo_id" = 1; 
     "jf_photo_url" = "http://adomainname/iphone_images/large/jf_largeimage1.png"; 
     "jf_user_id" = 1; 
     comments = (
      { 
       "jf_photo_comment" = "well i like this one. really. comment from janus"; 
       "jf_photo_comment_id" = 1; 
       "jf_photo_id" = 1; 
       "jf_user_id" = 1; 
       "jf_username" = janus; 
      }, 
      { 
       "jf_photo_comment" = asasfa; 
       "jf_photo_comment_id" = 4; 
       "jf_photo_id" = 1; 
       "jf_user_id" = 1; 
       "jf_username" = janus; 
      } 
     }; 
     likes = (
       { 
       "jf_like_id" = 2; 
       "jf_photo_id" = 1; 
       "jf_user_id" = 1; 
       "jf_username" = janus; 
      } 
     ,"post_date" = "2012-02-23 16:34:14"; 
    }, 

    { 
     "jf_photo_geotag" = "magalang philippines"; 
     "jf_photo_id" = 2; 
     "jf_photo_url" = "http://adomainname/iphone_images/large/jf_largeimage2.png"; 
     "jf_user_id" = 2; 
     comments =(
       { 
       "jf_photo_comment" = "well this is now a comment from loaclhost! for phot number 2"; 
       "jf_photo_comment_id" = 2; 
       "jf_photo_id" = 2; 
       "jf_user_id" = 2; 
       "jf_username" = fidel; 
      }, 
      { 
       "jf_photo_comment" = asdfadf; 
       "jf_photo_comment_id" = 3; 
       "jf_photo_id" = 2; 
       "jf_user_id" = 2; 
       "jf_username" = fidel; 
      }; 
     }; 
     likes = (
      { 
       "jf_like_id" = 1; 
       "jf_photo_id" = 2; 
       "jf_user_id" = 1; 
       "jf_username" = janus; 
      }; 
     }, 
     "post_date" = "2012-02-23 16:34:31"; 
    }, 
    { 
     "jf_photo_geotag" = "san fdo philippines"; 
     "jf_photo_id" = 3; 
     "jf_photo_url" = "http://adomainname/iphone_images/large/jf_largeimage1.png"; 
     "jf_user_id" = 3; 
     comments =    (
     ); 
     likes =    (
     ); 
     "post_date" = "2012-02-24 16:34:47"; 
    }; 
    }; 
success = 1; 

}

: 구조를 변경하고 생산 어쩌면이 일에 새 사전 유사를 만들 사전

첫 번째 사전에는 각 개체의 인덱스 번호가 있습니다. 나는 그들을 제거하고 싶다. 내 첫 번째 사전은 서버에서로드했으며, 두 번째는 plist에서 가져온 것입니다.

thanks you guys! 내 질문을 이해하길 바래.

답변

2

바깥 딕셔너리가 대신 배열이되는 것처럼 보입니다. 이 데이터를 NSDictionary에 이미 가지고 있다고 가정하면 다음과 같이 배열에 복사 할 수 있습니다.

+0

안녕 @ 배이저! 맞습니다. 정확히 코드 스 니펫을 시도해보고 알려 드리겠습니다. 감사! – janusbalatbat

관련 문제