iOS アプリで TMDB から人気の動画データを取得しています。しかし、そこから意味のあるデータを解析して取得するのに大きな問題があります。私はiOSがまったく初めてです。私はWindows Phoneで同様のことを行いました.Pocoを作成し、DataContractJsonSerializerを使用してデータを解析しました。しかし、iOSでこれを行う方法についてはまったくわかりません。この文字列から id、original_title、ポスター パスを取得したいと思います。
this is the data i am getting
{
buffer = {
0 = 123;
1 = 34;
10 = 34;
100 = 114;
3451 = 34;
3452 = 58;
3453 = 52;
3454 = 54;
3455 = 46;
3456 = 55;
3457 = 50;
3458 = 49;
3459 = 54;
346 = 110;
3460 = 49;
3461 = 48;
// lot of number in between
977 = 87;
978 = 75;
979 = 68;
98 = 34;
980 = 108;
981 = 51;
982 = 88;
983 = 97;
984 = 98;
985 = 99;
986 = 112;
987 = 72;
988 = 82;
989 = 110;
99 = 111;
990 = 110;
991 = 76;
992 = 77;
993 = 75;
994 = 102;
995 = 85;
996 = 46;
997 = 106;
998 = 112;
999 = 103;
length = 5810;
};
};
cookies = {
};
data = {
page = 1;
results = (
{
adult = 0;
"backdrop_path" = "/AdRL6c4BoMJgk7ZFUB2oUVzav2p.jpg";
id = 41602;
"original_title" = "The Necessary Death of Charlie Countryman";
popularity = "110.726084305053";
"poster_path" = "/fSwdCCGmO50IMaH4XMAixjclLDF.jpg";
"release_date" = "2013-11-15";
title = "The Necessary Death of Charlie Countryman";
"vote_average" = "7.5";
"vote_count" = 37;
},
{
adult = 0;
"backdrop_path" = "/mrvlpJFAzKwZZkLm9VD7Rh2VECi.jpg";
id = 116745;
"original_title" = "The Secret Life of Walter Mitty";
popularity = "64.2212199623452";
"poster_path" = "/v3e1LdwTXupH9L78eIWCKBjclhJ.jpg";
"release_date" = "2013-12-25";
title = "The Secret Life of Walter Mitty";
"vote_average" = "7.2";
"vote_count" = 124;
},
{
adult = 0;
"backdrop_path" = "/8aZHR0wXacn5DVYK3cS2ozWYPCN.jpg";
id = 64686;
"original_title" = "47 Ronin";
popularity = "95.9101659814315";
"poster_path" = "/v9JCVROrdlHZCWP3D6pnV8Xc29w.jpg";
"release_date" = "2013-12-25";
title = "47 Ronin";
"vote_average" = "6.5";
"vote_count" = 81;
},
{
adult = 0;
"backdrop_path" = "/zZTyJ6fbWKDl3XabcpHRnnLMKfU.jpg";
id = 249397;
"original_title" = "Nymphomaniac: Vol. II";
popularity = "94.03616025076791";
"poster_path" = "/pCW6krILJ2L0rXDXH0715teKTtm.jpg";
"release_date" = "2014-03-20";
title = "Nymphomaniac: Vol. II";
"vote_average" = "6.8";
"vote_count" = 11;
},
{
adult = 0;
"backdrop_path" = "/hyR7Fs6Tepgu3yCQGtgO4Ilz9tY.jpg";
id = 57158;
"original_title" = "The Hobbit: The Desolation of Smaug";
popularity = "88.3637510164635";
"poster_path" = "/gQCiuxGsfiXH1su6lp9n0nd0UeH.jpg";
"release_date" = "2013-12-13";
title = "The Hobbit: The Desolation of Smaug";
"vote_average" = "7.6";
"vote_count" = 434;
},
{
adult = 0;
"backdrop_path" = "/cAhCDpAq80QCeQvHytY9JkBalpH.jpg";
id = 109445;
"original_title" = Frozen;
popularity = "69.4628746979819";
"poster_path" = "/jIjdFXKUNtdf1bwqMrhearpyjMj.jpg";
"release_date" = "2013-11-19";
title = Frozen;
"vote_average" = "7.7";
"vote_count" = 348;
},
{
adult = 0;
"backdrop_path" = "/rP36Rx5RQh0rmH2ynEIaG8DxbV2.jpg";
id = 106646;
"original_title" = "The Wolf of Wall Street";
popularity = "64.6183486216064";
"poster_path" = "/wAgdJRx4uZ0u4uzu34NOMvtjLAR.jpg";
"release_date" = "2013-12-25";
title = "The Wolf of Wall Street";
"vote_average" = "7.9";
"vote_count" = 330;
},
{
adult = 0;
"backdrop_path" = "/r7Lmi2Jj1CJLdipYtLEU5iA4SB5.jpg";
id = 64807;
"original_title" = "Grudge Match";
popularity = "59.9853953814402";
"poster_path" = "/vzIIna3nvQAVGBBXbZgzvPSxg36.jpg";
"release_date" = "2013-12-25";
title = "Grudge Match";
"vote_average" = "6.6";
"vote_count" = 16;
},
{
adult = 0;
"backdrop_path" = "/mnxWdWTP3jbfxC4oaPrwevwvOZ2.jpg";
id = 53182;
"original_title" = "300: Rise of an Empire";
popularity = "49.8372271195572";
"poster_path" = "/d4kPMHsoTEH3FIkBDJM0uVOlas6.jpg";
"release_date" = "2014-03-07";
title = "300: Rise of an Empire";
"vote_average" = "6.6";
"vote_count" = 102;
},
{
adult = 0;
"backdrop_path" = "/rO75nODBBmJx4u5ZRy2BsGFgbO7.jpg";
id = 177494;
"original_title" = "Veronica Mars";
popularity = "48.7870515185193";
"poster_path" = "/nS3L07mQfcNJcisLEKgi8fWoBS1.jpg";
"release_date" = "2014-03-14";
title = "Veronica Mars";
"vote_average" = "7.2";
"vote_count" = 19;
},
{
adult = 0;
"backdrop_path" = "/iJtq3PHsLgjcYIrNlT2glzEdBo5.jpg";
id = 110415;
"original_title" = Snowpiercer;
popularity = "47.3945315956173";
"poster_path" = "/3J4QoMpQYE2MehOTQG9X2KUP4aq.jpg";
"release_date" = "2013-08-01";
title = Snowpiercer;
"vote_average" = "7.2";
"vote_count" = 29;
},
{
adult = 0;
"backdrop_path" = "/qMDiCjxfv6Y8JN2DFViTX5D1ORH.jpg";
id = 24253;
"original_title" = "Flickan som lekte med elden";
popularity = "46.7216104479466";
"poster_path" = "/qHRpU2d9NWB0WDulwgFwg6a9JRK.jpg";
"release_date" = "2009-09-18";
title = "The Girl Who Played with Fire";
"vote_average" = "6.8";
"vote_count" = 141;
},
{
adult = 0;
"backdrop_path" = "/1DfcGAQ4EVIZFnveo1IzHFtgFTS.jpg";
id = 175112;
"original_title" = "The Pirate Fairy";
popularity = "46.03463240154";
"poster_path" = "/6VmPnBPDCTbpZ3Jj5lbgHD10IZm.jpg";
"release_date" = "2014-04-01";
title = "The Pirate Fairy";
"vote_average" = "7.6";
"vote_count" = 5;
},
{
adult = 0;
"backdrop_path" = "/1RTiQXeHoEMXkZNWaB8W5uaEZ2.jpg";
id = 205220;
"original_title" = Philomena;
popularity = "45.1210557523094";
"poster_path" = "/6BTXHupSPkrwsoz4Br6qwwSVmhj.jpg";
"release_date" = "2013-11-27";
title = Philomena;
"vote_average" = "7.5";
"vote_count" = 31;
},
{
adult = 0;
"backdrop_path" = "/wRCPG1lsgfTFkWJ7G3eWgxCgv0C.jpg";
id = 101299;
"original_title" = "The Hunger Games: Catching Fire";
popularity = "41.4568100606251";
"poster_path" = "/tAhSyLxpaZJCr1oc2a3flvC2B7x.jpg";
"release_date" = "2013-11-22";
title = "The Hunger Games: Catching Fire";
"vote_average" = "7.7";
"vote_count" = 518;
},
{
adult = 0;
"backdrop_path" = "/hz3JfAikYXtaNWIJhWM4p5sy5OZ.jpg";
id = 49047;
"original_title" = Gravity;
popularity = "40.0573419755177";
"poster_path" = "/2gPjLWIyrWlAn2DgKMOKTBnZYyO.jpg";
"release_date" = "2013-10-04";
title = Gravity;
"vote_average" = "7.9";
"vote_count" = 751;
},
{
adult = 0;
"backdrop_path" = "/3FweBee0xZoY77uO1bhUOlQorNH.jpg";
id = 76338;
"original_title" = "Thor: The Dark World";
popularity = "38.5511611536454";
"poster_path" = "/aROh4ZwLfv9tmtOAsrnkYTbpujA.jpg";
"release_date" = "2013-11-08";
title = "Thor: The Dark World";
"vote_average" = "7.1";
"vote_count" = 503;
},
{
adult = 0;
"backdrop_path" = "/dNPmXYRS3nN4vD7MLtz5lP79DCB.jpg";
id = 11824;
"original_title" = "Teen Wolf";
popularity = "37.546317184227";
"poster_path" = "/3TKJbKNpHvRP8YVnwbgfok41AAC.jpg";
"release_date" = "1985-08-23";
title = "Teen Wolf";
"vote_average" = "7.1";
"vote_count" = 31;
},
{
adult = 0;
"backdrop_path" = "/kJzvjhJP6Xf7QQofVl3y0NvpwmI.jpg";
id = 256731;
"original_title" = "Bad Country";
popularity = "37.123709776744";
"poster_path" = "/6bjfGrtUYmuZzFCia3TcvY0Kz1e.jpg";
"release_date" = "2014-03-10";
title = "Bad Country";
"vote_average" = "5.5";
"vote_count" = 3;
},
{
adult = 0;
"backdrop_path" = "/6Ace8kIosYGnAiJUHgbLO4MNI6k.jpg";
id = 77067;
"original_title" = DeadHeads;
popularity = "36.41";
"poster_path" = "/A7kD47MEXywqKPeKHrxBfkvPTqy.jpg";
"release_date" = "2011-04-29";
title = DeadHeads;
"vote_average" = "5.8";
"vote_count" = 6;
}
);
"total_pages" = 7848;
"total_results" = 156953;
};
headers = {
"Access-Control-Allow-Origin" = "*";
Age = 3350;
"Cache-Control" = "public, max-age=14400";
Connection = "keep-alive";
"Content-Length" = 5810;
"Content-Type" = "application/json;charset=utf-8";
Date = "Sat, 29 Mar 2014 10:14:03 GMT";
ETag = "\"76070c8ebb216a66cbbc36e56c1407fa\"";
Server = nginx;
Status = "200 OK";
Vary = "Accept-Encoding";
Via = "1.0 localhost (squid/3.1.19)";
"X-Apiary-Ratelimit-Limit" = 120;
"X-Apiary-Ratelimit-Remaining" = 119;
"X-Apiary-Transaction-Id" = 53369cebed260702000005cc;
"X-Cache" = "HIT from localhost";
"X-Cache-Lookup" = "HIT from localhost:3128";
"X-Memc" = HIT;
"X-Memc-Age" = 12648;
"X-Memc-Expires" = 1752;
"X-Memc-Key" = eb13032fb1ef09086dcaac2d14c098c0;
};
status = 200;
text = "{\"page\":1,\"results\":[{\"adult\":false,\"backdrop_path\":\"/AdRL6c4BoMJgk7ZFUB2oUVzav2p.jpg\",\"id\":41602,\"original_title\":\"The Necessary Death of Charlie Countryman\",\"release_date\":\"2013-11-15\",\"poster_path\":\"/fSwdCCGmO50IMaH4XMAixjclLDF.jpg\",\"popularity\":110.726084305053,\"title\":\"The Necessary Death of Charlie Countryman\",\"vote_average\":7.5,\"vote_count\":37},{\"adult\":false,\"backdrop_path\":\"/mrvlpJFAzKwZZkLm9VD7Rh2VECi.jpg\",\"id\":116745,\"original_title\":\"The Secret Life of Walter Mitty\",\"release_date\":\"2013-12-25\",\"poster_path\":\"/v3e1LdwTXupH9L78eIWCKBjclhJ.jpg\",\"popularity\":64.2212199623452,\"title\":\"The Secret Life of Walter Mitty\",\"vote_average\":7.2,\"vote_count\":124},{\"adult\":false,\"backdrop_path\":\"/8aZHR0wXacn5DVYK3cS2ozWYPCN.jpg\",\"id\":64686,\"original_title\":\"47 Ronin\",\"release_date\":\"2013-12-25\",\"poster_path\":\"/v9JCVROrdlHZCWP3D6pnV8Xc29w.jpg\",\"popularity\":95.9101659814315,\"title\":\"47 Ronin\",\"vote_average\":6.5,\"vote_count\":81},{\"adult\":false,\"backdrop_path\":\"/zZTyJ6fbWKDl3XabcpHRnnLMKfU.jpg\",\"id\":249397,\"original_title\":\"Nymphomaniac: Vol. II\",\"release_date\":\"2014-03-20\",\"poster_path\":\"/pCW6krILJ2L0rXDXH0715teKTtm.jpg\",\"popularity\":94.0361602507679,\"title\":\"Nymphomaniac: Vol. II\",\"vote_average\":6.8,\"vote_count\":11},{\"adult\":false,\"backdrop_path\":\"/hyR7Fs6Tepgu3yCQGtgO4Ilz9tY.jpg\",\"id\":57158,\"original_title\":\"The Hobbit: The Desolation of Smaug\",\"release_date\":\"2013-12-13\",\"poster_path\":\"/gQCiuxGsfiXH1su6lp9n0nd0UeH.jpg\",\"popularity\":88.3637510164635,\"title\":\"The Hobbit: The Desolation of Smaug\",\"vote_average\":7.6,\"vote_count\":434},{\"adult\":false,\"backdrop_path\":\"/cAhCDpAq80QCeQvHytY9JkBalpH.jpg\",\"id\":109445,\"original_title\":\"Frozen\",\"release_date\":\"2013-11-19\",\"poster_path\":\"/jIjdFXKUNtdf1bwqMrhearpyjMj.jpg\",\"popularity\":69.4628746979819,\"title\":\"Frozen\",\"vote_average\":7.7,\"vote_count\":348},{\"adult\":false,\"backdrop_path\":\"/rP36Rx5RQh0rmH2ynEIaG8DxbV2.jpg\",\"id\":106646,\"original_title\":\"The Wolf of Wall Street\",\"release_date\":\"2013-12-25\",\"poster_path\":\"/wAgdJRx4uZ0u4uzu34NOMvtjLAR.jpg\",\"popularity\":64.6183486216064,\"title\":\"The Wolf of Wall Street\",\"vote_average\":7.9,\"vote_count\":330},{\"adult\":false,\"backdrop_path\":\"/r7Lmi2Jj1CJLdipYtLEU5iA4SB5.jpg\",\"id\":64807,\"original_title\":\"Grudge Match\",\"release_date\":\"2013-12-25\",\"poster_path\":\"/vzIIna3nvQAVGBBXbZgzvPSxg36.jpg\",\"popularity\":59.9853953814402,\"title\":\"Grudge Match\",\"vote_average\":6.6,\"vote_count\":16},{\"adult\":false,\"backdrop_path\":\"/mnxWdWTP3jbfxC4oaPrwevwvOZ2.jpg\",\"id\":53182,\"original_title\":\"300: Rise of an Empire\",\"release_date\":\"2014-03-07\",\"poster_path\":\"/d4kPMHsoTEH3FIkBDJM0uVOlas6.jpg\",\"popularity\":49.8372271195572,\"title\":\"300: Rise of an Empire\",\"vote_average\":6.6,\"vote_count\":102},{\"adult\":false,\"backdrop_path\":\"/rO75nODBBmJx4u5ZRy2BsGFgbO7.jpg\",\"id\":177494,\"original_title\":\"Veronica Mars\",\"release_date\":\"2014-03-14\",\"poster_path\":\"/nS3L07mQfcNJcisLEKgi8fWoBS1.jpg\",\"popularity\":48.7870515185193,\"title\":\"Veronica Mars\",\"vote_average\":7.2,\"vote_count\":19},{\"adult\":false,\"backdrop_path\":\"/iJtq3PHsLgjcYIrNlT2glzEdBo5.jpg\",\"id\":110415,\"original_title\":\"Snowpiercer\",\"release_date\":\"2013-08-01\",\"poster_path\":\"/3J4QoMpQYE2MehOTQG9X2KUP4aq.jpg\",\"popularity\":47.3945315956173,\"title\":\"Snowpiercer\",\"vote_average\":7.2,\"vote_count\":29},{\"adult\":false,\"backdrop_path\":\"/qMDiCjxfv6Y8JN2DFViTX5D1ORH.jpg\",\"id\":24253,\"original_title\":\"Flickan som lekte med elden\",\"release_date\":\"2009-09-18\",\"poster_path\":\"/qHRpU2d9NWB0WDulwgFwg6a9JRK.jpg\",\"popularity\":46.7216104479466,\"title\":\"The Girl Who Played with Fire\",\"vote_average\":6.8,\"vote_count\":141},{\"adult\":false,\"backdrop_path\":\"/1DfcGAQ4EVIZFnveo1IzHFtgFTS.jpg\",\"id\":175112,\"original_title\":\"The Pirate Fairy\",\"release_date\":\"2014-04-01\",\"poster_path\":\"/6VmPnBPDCTbpZ3Jj5lbgHD10IZm.jpg\",\"popularity\":46.03463240154,\"title\":\"The Pirate Fairy\",\"vote_average\":7.6,\"vote_count\":5},{\"adult\":false,\"backdrop_path\":\"/1RTiQXeHoEMXkZNWaB8W5uaEZ2.jpg\",\"id\":205220,\"original_title\":\"Philomena\",\"release_date\":\"2013-11-27\",\"poster_path\":\"/6BTXHupSPkrwsoz4Br6qwwSVmhj.jpg\",\"popularity\":45.1210557523094,\"title\":\"Philomena\",\"vote_average\":7.5,\"vote_count\":31},{\"adult\":false,\"backdrop_path\":\"/wRCPG1lsgfTFkWJ7G3eWgxCgv0C.jpg\",\"id\":101299,\"original_title\":\"The Hunger Games: Catching Fire\",\"release_date\":\"2013-11-22\",\"poster_path\":\"/tAhSyLxpaZJCr1oc2a3flvC2B7x.jpg\",\"popularity\":41.4568100606251,\"title\":\"The Hunger Games: Catching Fire\",\"vote_average\":7.7,\"vote_count\":518},{\"adult\":false,\"backdrop_path\":\"/hz3JfAikYXtaNWIJhWM4p5sy5OZ.jpg\",\"id\":49047,\"original_title\":\"Gravity\",\"release_date\":\"2013-10-04\",\"poster_path\":\"/2gPjLWIyrWlAn2DgKMOKTBnZYyO.jpg\",\"popularity\":40.0573419755177,\"title\":\"Gravity\",\"vote_average\":7.9,\"vote_count\":751},{\"adult\":false,\"backdrop_path\":\"/3FweBee0xZoY77uO1bhUOlQorNH.jpg\",\"id\":76338,\"original_title\":\"Thor: The Dark World\",\"release_date\":\"2013-11-08\",\"poster_path\":\"/aROh4ZwLfv9tmtOAsrnkYTbpujA.jpg\",\"popularity\":38.5511611536454,\"title\":\"Thor: The Dark World\",\"vote_average\":7.1,\"vote_count\":503},{\"adult\":false,\"backdrop_path\":\"/dNPmXYRS3nN4vD7MLtz5lP79DCB.jpg\",\"id\":11824,\"original_title\":\"Teen Wolf\",\"release_date\":\"1985-08-23\",\"poster_path\":\"/3TKJbKNpHvRP8YVnwbgfok41AAC.jpg\",\"popularity\":37.546317184227,\"title\":\"Teen Wolf\",\"vote_average\":7.1,\"vote_count\":31},{\"adult\":false,\"backdrop_path\":\"/kJzvjhJP6Xf7QQofVl3y0NvpwmI.jpg\",\"id\":256731,\"original_title\":\"Bad Country\",\"release_date\":\"2014-03-10\",\"poster_path\":\"/6bjfGrtUYmuZzFCia3TcvY0Kz1e.jpg\",\"popularity\":37.123709776744,\"title\":\"Bad Country\",\"vote_average\":5.5,\"vote_count\":3},{\"adult\":false,\"backdrop_path\":\"/6Ace8kIosYGnAiJUHgbLO4MNI6k.jpg\",\"id\":77067,\"original_title\":\"DeadHeads\",\"release_date\":\"2011-04-29\",\"poster_path\":\"/A7kD47MEXywqKPeKHrxBfkvPTqy.jpg\",\"popularity\":36.41,\"title\":\"DeadHeads\",\"vote_average\":5.8,\"vote_count\":6}],\"total_pages\":7848,\"total_results\":156953}";
uuid = "bb4cca64-b0c4-0308-b92f-49980466092c";
今まで試したコード
[MYCloud callFunctionInBackground:@"popularMovie"
withParameters:@{@"movie": @" "}
block:^(id response, NSError *error) {
if (!error) {
// ratings is 4.5
NSArray *movieArray;
movieArray = [response allValues];
NSDictionary *firstObject = [movieArray objectAtIndex:0];
NSDictionary *entities = [firstObject objectForKey:@"results"];
NSLog(@"json :%@",[response description]);
NSDictionary *entities = [firstObject objectForKey:@"results"]; でクラッシュします。
================================================== ==================================== これは試行時のクラッシュログです
NSDictionary *blah = [NSJSONSerialization JSONObjectWithData:response options:0 error:nil];
2014-03-29 16:21:48.572 Moviez[6804:60b] -[__NSDictionaryM bytes]: unrecognized selector sent to instance 0x9daf000
2014-03-29 16:21:48.575 Moviez[6804:60b] * キャッチされない例外 'NSInvalidArgumentException' が原因でアプリを終了します。 0 CoreFoundation 0x026271e4 exceptionPreprocess + 180 1 libobjc.A.dylib 0x023a68e5 objc_exception_throw + 44 2 CoreFoundation 0x026c4243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275 3 CoreFoundation 0x0261750b __転送+ 1019 4 CoreFoundation 0x026170ee _CF_forwarding_prep_0 + 14 5 ファンデーション 0x020ec4bc -[_NSJSONReader findEncodingFromData:withBOMSkipLength:] + 36 6 ファンデーション 0x020ec66b -[_NSJSONReader parseData:options:] + 63 7 ファンデーション 0x020ecc30ムービーズ 0x0000288432-[HILViewController viewDidLoad]_block_invoke + 212 9 Moviez 0x00053f47 __40-[PFTask thenCallBackOnMainThreadAsync:]_block_invoke_2 + 241 10 libdispatch.dylib 0x02c7a7b8 _dispatch_call_block_and_release + 15 11 libdispatch.dylib 0x02c8f4d0 _dispatch_client_callout + 14 12 libdispatch.dylib 0x02c7d726 _dispatch_main_queue_callback_4CF + 340 13 CoreFoundation 0x0268c43e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE+ 14 14 CoreFoundation 0x025cd5cb __CFRunLoopRun + 1963 15 CoreFoundation 0x025cc9d3 CFRunLoopRunSpecific + 467 16 CoreFoundation 0x025cc7eb CFRunLoopRunInMode + 123 17 GraphicsServices 0x0420b5ee GSEventRunModal + 192 18 GraphicsServices 0x0420b42b GSEventRun + 104 19 UIKit 0x01066f9b UIApplicationMain + 1225 20 Moviez 0x00002ded main + 141 21 libdyld.dylib 0x02ec4701 start + 1 ) libc++abi.dylib: タイプ NSException のキャッチされない例外で終了します