-5

我正在尝试从 Twitter 帐户中获取关注者列表。我需要从这些朋友那里得到一份名单。

我正在尝试使用以下代码获取具有这些名称的数组:

NSArray *users = [twitterFriends objectForKey:@"name"];

但它崩溃了..

这是我的json回复。

(
    {
    "contributors_enabled" = 0;
    "created_at" = "Thu Aug 12 20:43:32 +0000 2010";
    "default_profile" = 0;
    "default_profile_image" = 0;
    description = "Software House, Business Plan, Consultoria Empresarial, BPM, JJAERP";
    entities =         {
        description =             {
            urls =                 (
            );
        };
        url =             {
            urls =                 (
                                    {
                    "display_url" = "jjaconsulting.com.br";
                    indices =                         (
                        0,
                        22
                    );
                    url = "http://t.co/9KuqGoNcTh";
                }
            );
        };
    };
    "favourites_count" = 0;
    "follow_request_sent" = 0;
    "followers_count" = 46;
    following = 0;
    "friends_count" = 227;
    "geo_enabled" = 1;
    id = 177691414;
    "id_str" = 177691414;
    "is_translator" = 0;
    lang = pt;
    "listed_count" = 0;
    location = " Campinas/SP ";
    name = "JJA Consulting";
    notifications = 0;
    "profile_background_color" = 0099B9;
    "profile_background_image_url" = "http://a0.twimg.com/profile_background_images/378800000039639419/aed884dcff4f8d9aad7c8ae74bc9a151.jpeg";
    "profile_background_image_url_https" = "https://si0.twimg.com/profile_background_images/378800000039639419/aed884dcff4f8d9aad7c8ae74bc9a151.jpeg";
    "profile_background_tile" = 0;
    "profile_image_url" = "http://a0.twimg.com/profile_images/2759565559/f0da5bb0cf89e41c063758dd4a2266b2_normal.png";
    "profile_image_url_https" = "https://si0.twimg.com/profile_images/2759565559/f0da5bb0cf89e41c063758dd4a2266b2_normal.png";
    "profile_link_color" = 0099B9;
    "profile_sidebar_border_color" = FFFFFF;
    "profile_sidebar_fill_color" = 95E8EC;
    "profile_text_color" = 3C3940;
    "profile_use_background_image" = 1;
    protected = 0;
    "screen_name" = JJAConsulting;
    status =         {
        contributors = "<null>";
        coordinates = "<null>";
        "created_at" = "Wed Aug 07 20:20:15 +0000 2013";
        entities =             {
            hashtags =                 (
            );
            symbols =                 (
            );
            urls =                 (
                                    {
                    "display_url" = "wp.me/p3yYQw-dX";
                    "expanded_url" = "http://wp.me/p3yYQw-dX";
                    indices =                         (
                        33,
                        55
                    );
                    url = "http://t.co/c0lw6XTXhr";
                }
            );
            "user_mentions" =                 (
            );
        };
        "favorite_count" = 0;
        favorited = 0;
        geo = "<null>";
        id = 365205769249357825;
        "id_str" = 365205769249357825;
        "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>";
        lang = pt;
        place = "<null>";
        "possibly_sensitive" = 0;
        "retweet_count" = 0;
        retweeted = 0;
        source = "<a href=\"http://publicize.wp.com/\" rel=\"nofollow\">WordPress.com</a>";
        text = "JXML - Mensageria JJA Consulting http://t.co/c0lw6XTXhr";
        truncated = 0;
    };
    "statuses_count" = 1731;
    "time_zone" = Brasilia;
    url = "http://t.co/9KuqGoNcTh";
    "utc_offset" = "-10800";
    verified = 0;
},
    {
    "contributors_enabled" = 0;
    "created_at" = "Sun Aug 14 18:52:23 +0000 2011";
    "default_profile" = 1;
    "default_profile_image" = 0;
    description = "";
    entities =         {
        description =             {
            urls =                 (
            );
        };
        url =             {
            urls =                 (
                                    {
                    "display_url" = "atacadaomicrotech.com.br";
                    "expanded_url" = "http://www.atacadaomicrotech.com.br/";
                    indices =                         (
                        0,
                        22
                    );
                    url = "http://t.co/wbPX342NF2";
                }
            );
        };
    };
    "favourites_count" = 1;
    "follow_request_sent" = 0;
    "followers_count" = 13;
    following = 0;
    "friends_count" = 115;
    "geo_enabled" = 1;
    id = 355045961;
    "id_str" = 355045961;
    "is_translator" = 0;
    lang = pt;
    "listed_count" = 0;
    location = "Ribas do Rio Pardo - MS";
    name = "Microtech Info";
    notifications = 0;
    "profile_background_color" = C0DEED;
    "profile_background_image_url" = "http://a0.twimg.com/images/themes/theme1/bg.png";
    "profile_background_image_url_https" = "https://si0.twimg.com/images/themes/theme1/bg.png";
    "profile_background_tile" = 0;
    "profile_image_url" = "http://a0.twimg.com/profile_images/1495205945/microtech_normal.jpg";
    "profile_image_url_https" = "https://si0.twimg.com/profile_images/1495205945/microtech_normal.jpg";
    "profile_link_color" = 0084B4;
    "profile_sidebar_border_color" = C0DEED;
    "profile_sidebar_fill_color" = DDEEF6;
    "profile_text_color" = 333333;
    "profile_use_background_image" = 1;
    protected = 0;
4

1 回答 1

0

假设twitterFriends是字典的根数组,您可以通过以下方式获取名称列表:

NSArray *names = [twitterFriends valueForKeyPath:@"name"];
于 2013-08-12T15:24:53.023 回答