Сенсорный JSON проблемы с Twitter на iOS

Я пытаюсь проанализировать обновления статуса пользователя в JSON, возвращенные из Twitter:

NSDictionary *publicTimeline = [NSDictionary dictionaryWithJSONData:responseData error:&jsonParsingError];
NSLog(@"%@ - %@",publicTimeline,[publicTimeline class]);

Это даст мне очень аккуратно выглядящий JSON, возвращенный из Twitter, но он говорит, что класс _NSArrayI - это уже сбивает с толку, но я предполагаю, что это какая-то особенность Touch JSON.

Когда у меня есть словарь, я не могу понять, как с ним что-то сделать. Если я попробую:

NSArray *array = [publicTimeline allKeys];

или же

NSArray *tweetsArray = [dict objectForKey:@"results"];

... происходит сбой из-за нераспознанного селектора.

Я не могу найти практических примеров того, как использовать библиотеку Touch JSON для фактического захвата объектов. Я имею в виду, как я могу получить первый твит? Как насчет даты внутри этого твита?

РЕДАКТИРОВАТЬ: Это то, что NSLog говорит, что выглядит так:

(
    {
    contributors = "<null>";
    coordinates = "<null>";
    "created_at" = "Thu May 03 05:04:05 +0000 2012";
    favorited = 0;
    geo = "<null>";
    id = 197914401796403200;
    "id_str" = 197914401796403200;
    "in_reply_to_screen_name" = "<null>";
    "in_reply_to_status_id" = "<null>";
    "in_reply_to_status_id_str" = "<null>";
    "in_reply_to_user_id" = "<null>";
    "in_reply_to_user_id_str" = "<null>";
    place = "<null>";
    "retweet_count" = 4;
    retweeted = 0;
    source = "<a href=\"http://ubersocial.com\" rel=\"nofollow\">UberSocial for BlackBerry</a>";
    text = "Hear hear RT @saarsaar I am excited that more &amp; more entrepreneurs seem to be favoring VCs who help most, care most, &amp; love product";
    truncated = 0;
    user =         {
        "contributors_enabled" = 0;
        "created_at" = "Thu Apr 26 06:43:28 +0000 2007";
        "default_profile" = 0;
        "default_profile_image" = 0;
        description = "2x entrepreneur. Sold both companies (last to salesforce.com). Turned VC looking to invest in passionate entrepreneurs";
        "favourites_count" = 49;
        "follow_request_sent" = "<null>";
        "followers_count" = 65580;
        following = "<null>";
        "friends_count" = 835;
        "geo_enabled" = 0;
        id = 5520332;
        "id_str" = 5520332;
        "is_translator" = 0;
        lang = en;
        "listed_count" = 4501;
        location = "Los Angeles";
        name = "Mark Suster";
        notifications = "<null>";
        "profile_background_color" = 9AE4E8;
        "profile_background_image_url" = "http://a0.twimg.com/profile_background_images/4977283/s_sunset23.jpg";
        "profile_background_image_url_https" = "https://si0.twimg.com/profile_background_images/4977283/s_sunset23.jpg";
        "profile_background_tile" = 1;
        "profile_image_url" = "http://a0.twimg.com/profile_images/85156906/msuster_fb_normal.jpg";
        "profile_image_url_https" = "https://si0.twimg.com/profile_images/85156906/msuster_fb_normal.jpg";
        "profile_link_color" = 0000FF;
        "profile_sidebar_border_color" = 87BC44;
        "profile_sidebar_fill_color" = E0FF92;
        "profile_text_color" = 000000;
        "profile_use_background_image" = 1;
        protected = 0;
        "screen_name" = msuster;
        "show_all_inline_media" = 1;
        "statuses_count" = 14592;
        "time_zone" = "Pacific Time (US & Canada)";
        url = "http://bothsid.es";
        "utc_offset" = "-28800";
        verified = 0;
    };
},
    {
    contributors = "<null>";
    coordinates = "<null>";
    "created_at" = "Wed May 02 04:37:36 +0000 2012";
    favorited = 0;
    geo = "<null>";
    id = 197545349622153217;
    "id_str" = 197545349622153217;
    "in_reply_to_screen_name" = "<null>";
    "in_reply_to_status_id" = "<null>";
    "in_reply_to_status_id_str" = "<null>";
    "in_reply_to_user_id" = "<null>";
    "in_reply_to_user_id_str" = "<null>";
    place = "<null>";
    "retweet_count" = 23;
    retweeted = 0;
    "retweeted_status" =         {
        contributors = "<null>";
        coordinates = "<null>";
        "created_at" = "Wed May 02 04:21:30 +0000 2012";
        favorited = 0;
        geo = "<null>";
        id = 197541298746568704;
        "id_str" = 197541298746568704;
        "in_reply_to_screen_name" = "<null>";
        "in_reply_to_status_id" = "<null>";
        "in_reply_to_status_id_str" = "<null>";
        "in_reply_to_user_id" = "<null>";
        "in_reply_to_user_id_str" = "<null>";
        place = "<null>";
        "retweet_count" = 23;
        retweeted = 0;
        source = "<a href=\"http://twitter.com/#!/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>";
        text = "When I hear the word 'pivot', in my head I hear the sound of a toilet flushing. Cc @infoarbitrage @msuster";
        truncated = 0;
        user =             {
            "contributors_enabled" = 0;
            "created_at" = "Tue Apr 22 13:08:40 +0000 2008";
            "default_profile" = 0;
            "default_profile_image" = 0;
            description = "Entrepreneur turned Investor. Chief Firestarter at @K9Ventures. Tags: tech entrepreneur startups angel investor concept seed web venture vc cmu stanford";
            "favourites_count" = 7;
            "follow_request_sent" = "<null>";
            "followers_count" = 9732;
            following = "<null>";
            "friends_count" = 1009;
            "geo_enabled" = 1;
            id = 14474225;
            "id_str" = 14474225;
            "is_translator" = 0;
            lang = en;
            "listed_count" = 628;
            location = "Palo Alto, CA";
            name = "Manu Kumar";
            notifications = "<null>";
            "profile_background_color" = 303030;
            "profile_background_image_url" = "http://a0.twimg.com/profile_background_images/3375189/logo90x100__with_margin_.png";
            "profile_background_image_url_https" = "https://si0.twimg.com/profile_background_images/3375189/logo90x100__with_margin_.png";
            "profile_background_tile" = 0;
            "profile_image_url" = "http://a0.twimg.com/profile_images/1772187320/Manu_Kumar__813x961__normal.jpg";
            "profile_image_url_https" = "https://si0.twimg.com/profile_images/1772187320/Manu_Kumar__813x961__normal.jpg";
            "profile_link_color" = F6901E;
            "profile_sidebar_border_color" = 999999;
            "profile_sidebar_fill_color" = 626465;
            "profile_text_color" = 303030;
            "profile_use_background_image" = 1;
            protected = 0;
            "screen_name" = ManuKumar;
            "show_all_inline_media" = 1;
            "statuses_count" = 11234;
            "time_zone" = "Pacific Time (US & Canada)";
            url = "http://www.k9ventures.com";
            "utc_offset" = "-28800";
            verified = 0;
        };
    };
    source = web;
    text = "RT @ManuKumar: When I hear the word 'pivot', in my head I hear the sound of a toilet flushing. Cc @infoarbitrage @msuster";
    truncated = 0;
    user =         {
        "contributors_enabled" = 0;
        "created_at" = "Thu Apr 26 06:43:28 +0000 2007";
        "default_profile" = 0;
        "default_profile_image" = 0;
        description = "2x entrepreneur. Sold both companies (last to salesforce.com). Turned VC looking to invest in passionate entrepreneurs";
        "favourites_count" = 49;
        "follow_request_sent" = "<null>";
        "followers_count" = 65580;
        following = "<null>";
        "friends_count" = 835;
        "geo_enabled" = 0;
        id = 5520332;
        "id_str" = 5520332;
        "is_translator" = 0;
        lang = en;
        "listed_count" = 4501;
        location = "Los Angeles";
        name = "Mark Suster";
        notifications = "<null>";
        "profile_background_color" = 9AE4E8;
        "profile_background_image_url" = "http://a0.twimg.com/profile_background_images/4977283/s_sunset23.jpg";
        "profile_background_image_url_https" = "https://si0.twimg.com/profile_background_images/4977283/s_sunset23.jpg";
        "profile_background_tile" = 1;
        "profile_image_url" = "http://a0.twimg.com/profile_images/85156906/msuster_fb_normal.jpg";
        "profile_image_url_https" = "https://si0.twimg.com/profile_images/85156906/msuster_fb_normal.jpg";
        "profile_link_color" = 0000FF;
        "profile_sidebar_border_color" = 87BC44;
        "profile_sidebar_fill_color" = E0FF92;
        "profile_text_color" = 000000;
        "profile_use_background_image" = 1;
        protected = 0;
        "screen_name" = msuster;
        "show_all_inline_media" = 1;
        "statuses_count" = 14592;
        "time_zone" = "Pacific Time (US & Canada)";
        url = "http://bothsid.es";
        "utc_offset" = "-28800";
        verified = 0;
    };
}

)

1 ответ

Это массив всего с двумя объектами (я думаю, я не могу выстроить все фигурные скобки), поэтому попробуйте использовать objectAtIndex:0, чтобы получить первый словарь, и посмотрите, решит ли это вашу проблему.

Другие вопросы по тегам