开发者

How do I properly populate the UITableView NSArray from a NSDictionary created using JSONKit?

Sorry for the long question but that best summarizes what I am trying to do:

My JSON Looks like:

{
    4e8cf1d6c7e24c063e000000 =     {
        "_id" =         {
            "$id" = 4e8cf1d6c7e24c063e000000;
        };
        author = faisal;
        comments =         (
                        {
                author = adias;
                comment = amazing;
            },
                        {
                author = nike;
                comment = "I concur";
            }
        );
        created =         {
            sec = 1317772800;
            usec = 0;
   开发者_Go百科     };
        text = "This is a random post";
        title = "post # 1";
        type =         (
            punjabi
        );
    };
    4e91fd49c7e24cda74000000 =     {
        "_id" =         {
            "$id" = 4e91fd49c7e24cda74000000;
        };
        author = draper;
        comments =         (
                        {
                author = adias;
                comment = "amazing again";
            }
        );
        created =         {
            sec = 1318118400;
            usec = 0;
        };
        text = "This is a random post again";
        title = "post # 2";
        type =         (
            punjabi
        );
    };
}

What I would like to do is to ultimately have a UTTableview with each row having a title (text from above JSON):

This is the code I have so far:

NSString *responseString = [request responseString];

   NSDictionary *resultsDictionary = [responseString objectFromJSONString];

How do I put everything in an array for the UITableView? Again I am just a little rusty as I can swear I have done that before.


If you don't need the keys then you can convert it to an array by using allValues, e.g.:

NSArray *values = [resultsDictionary allValues];


Does your JSON really parse to an NSDictionary, or is this an NSArray containing NSDictionary instances? If the latter, then isn't it just something like:

NSString *textForCell = [[resultsArray objectAtIndex:row] valueForKey:@"title"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜