2012-02-09 3 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; 

}

:その構造を変更し、生産し、多分この1に新しい辞書に類似を作成する辞書

最初の辞書に各オブジェクトのインデックス番号が付いていることに注目してください。私はそれらを削除したい。 私の最初の辞書はサーバからロードされ、2番目の辞書はplistからのものです

ありがとう皆さん!あなたが私の質問を理解することを願っています

答えて

2

外側の辞書を代わりに配列にしたいようです。 NSDictionaryのこのデータを既に持っていると仮定すると、次のように配列にコピーすることができます。

+0

こんにちは@badger!確かに..コードスニペットを試してみましょう!ありがとう! – janusbalatbat

関連する問題