NSDictionary中的objectAtIndex

时间:2011-11-19 06:25:48

标签: iphone ios nsdictionary

我正在尝试从我的NSDictionary创建UITableView,但是如何使用objectForKey?转换为NSArray? 我需要帮助。 我的字典看起来像: **

{
    "allow_comments" = 1;
    category = 1024194;
    "created_at" = "2011-11-17T01:44";
    forum = 1005401;
    "forum_obj" =     {
        "created_at" = "2011-09-03 03:04:43.514514";
        description = "";
        id = 1005401;
        name = smartfiction;
        shortname = smartfiction;
    };
    hidden = 0;
    id = 474530565;
    identifier =     (
        "2507 http://smartfiction.ru/?p=2507"
    );
    "num_comments" = 2;
    slug = "thread_9714";
    title = "\U041e\U0440\U0438\U0444\U043b\U0430\U043c\U043c\U0430. \U042d\U0436\U0435\U043d \U0418\U043e\U043d\U0435\U0441\U043a\U043e";
    url = "http://smartfiction.ru/prose/oriflamma/";
}
2011-11-19 10:21:25.992 ARSSReader[3067:15503] id 474530565
2011-11-19 10:21:26.864 ARSSReader[3067:15503] Ответ #2: (
        {
        author =         {
            avatar =             {
                cache = "http://www.gravatar.com/avatar.php?gravatar_id=af6c6f08e213427ad611b00589db00f9&size=32&default=http://mediacdn.disqus.com/1321567697/images/noavatar32.png";
                permalink = "http://www.gravatar.com/avatar.php?gravatar_id=af6c6f08e213427ad611b00589db00f9&size=32&default=http://mediacdn.disqus.com/1321567697/images/noavatar32.png";
            };
            emailHash = af6c6f08e213427ad611b00589db00f9;
            isAnonymous = 1;
            name = "S Shv";
            profileUrl = "http://disqus.com/guest/af6c6f08e213427ad611b00589db00f9/";
            url = "";
        };
        createdAt = "2011-11-17T22:39:36";
        dislikes = 0;
        forum = smartfiction;
        id = 367003621;
        isApproved = 1;
        isDeleted = 0;
        isEdited = 0;
        isFlagged = 0;
        isHighlighted = 0;
        isJuliaFlagged = 1;
        isSpam = 0;
        likes = 0;
        media =         (
        );
        message = "\U043f\U043e\U0440\U0430\U0437\U0438\U043b\U043e )";
        parent = "<null>";
        points = 0;
        "raw_message" = "\U043f\U043e\U0440\U0430\U0437\U0438\U043b\U043e )";
        thread = 474530565;
    },
        {
        author =         {
            avatar =             {
                cache = "http://www.gravatar.com/avatar.php?gravatar_id=c1c53088e04a60aab74cd1f149117e69&size=32&default=http://mediacdn.disqus.com/1321567697/images/noavatar32.png";
                permalink = "http://www.gravatar.com/avatar.php?gravatar_id=c1c53088e04a60aab74cd1f149117e69&size=32&default=http://mediacdn.disqus.com/1321567697/images/noavatar32.png";
            };
            emailHash = c1c53088e04a60aab74cd1f149117e69;
            isAnonymous = 1;
            name = "3,14";
            profileUrl = "http://disqus.com/guest/c1c53088e04a60aab74cd1f149117e69/";
            url = "";
        };
        createdAt = "2011-11-17T02:52:46";
        dislikes = 0;
        forum = smartfiction;
        id = 365544459;
        isApproved = 1;
        isDeleted = 0;
        isEdited = 0;
        isFlagged = 0;
        isHighlighted = 0;
        isJuliaFlagged = 1;
        isSpam = 0;
        likes = 1;
        media =         (
        );
        message = "\U0427\U0438\U0442\U0430\U0442\U044c \U043d\U0430 \U043d\U043e\U0447\U044c \U043f\U0440\U043e\U043a\U0440\U0430\U0441\U0442\U0438\U043d\U0430\U0442\U043e\U0440\U0430\U043c. \U0412\U043f\U0440\U043e\U0447\U0435\U043c, \U043b\U0443\U0447\U0448\U0435 \U0443\U0442\U0440\U043e\U043c.";
        parent = "<null>";
        points = 1;
        "raw_message" = "\U0427\U0438\U0442\U0430\U0442\U044c \U043d\U0430 \U043d\U043e\U0447\U044c \U043f\U0440\U043e\U043a\U0440\U0430\U0441\U0442\U0438\U043d\U0430\U0442\U043e\U0440\U0430\U043c. \U0412\U043f\U0440\U043e\U0447\U0435\U043c, \U043b\U0443\U0447\U0448\U0435 \U0443\U0442\U0440\U043e\U043c.";
        thread = 474530565;
    }
)

** 这是来自disqus.com的评论。我想为所有注释创建字典,并使用它们来创建UITableView单元格。

1 个答案:

答案 0 :(得分:0)

不是将disqus.com中的注释存储在字典中,而是将每个注释存储在数组中的条目中(看起来每个注释都有一个文本块,您可以将其封装到可以存储到数组中的对象中) 。

字典适用于将值与键相关联。

数组非常适合存储对象列表,就像来自disqus站点的注释列表一样。