如何解析从iOS中的TMDB收到的这个字符串

时间:2014-03-29 10:31:00

标签: ios json themoviedb-api

我在iOS App中从TMDB获取流行的电影数据。但是我在解析和从中获取有意义的数据时遇到了很大麻烦。我是iOS新手。我在Windows Phone中做过类似的事情,我创建了Poco,并使用DataContractJsonSerializer来解析数据。 但我不知道如何在iOS中这样做。 我想从这个字符串中检索id,original_title和poster路径。

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',原因:' - [__ NSDictionaryM字节]:无法识别的选择器发送到实例0x9daf000' * 第一次抛出调用堆栈: (     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 + [NSJSONSerialization JSONObjectWithData:options:error:] + 161     8 Moviez 0x00002884 32- [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类型的未捕获异常终止

2 个答案:

答案 0 :(得分:1)

更新以匹配您获得的完整数据

正如你所说,响应已经是一个NSDictionary,所以你的代码应该是这样的......

// Results is an Array of movie entries
NSDictionary *movieData = [response objectForKey:@"data"];
NSArray * movieArray = [movieData objectForKey:@"results"];
NSDictionary *firstObject = [movieArray objectAtIndex:0];

或者在现代目标c中你可以做到

NSDictionary *movieData = response[@"data"];
NSArray * movieArray = movieData[@"results"];
NSDictionary *firstObject = movieArray[0];

或者如果你真的相信它总会包含你可以做的事情

NSDictionary *firstObject = response[@"data"][@"results"][0];

(我认为)

答案 1 :(得分:0)

顶级对象是NSDictionary。

因此...

NSDictionary *blah = [NSJSONSerialization JSONObjectWithData:theData options:0 error:nil];

这会将数据转换为您可以使用的对象。