MGTwitterEngine和iPhone [英] MGTwitterEngine and iPhone

查看:109
本文介绍了MGTwitterEngine和iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了MGTwitterEngine并添加到我的iPhone项目中。它是连接并获得我可以告诉他们将它们转储到NSLog中的雕像。但是,我无法弄清楚我需要如何解析调用,以便将它们添加到表中。它们作为NSString返回,如下所示:

I downloaded MGTwitterEngine and added to my iPhone project. It's connecting and getting statues I can tell from dumping them into an NSLog. But, I can't figure out how how I need to parse the calls so I can add them to a table. They are returned as an NSString and look like this:

      {
    "created_at" = 2009-07-25 15:28:41 -0500;
    favorited = 0;
    id = 65;
    source = "<a href=\"http://twitter.com/\">Twitter</a>";
    "source_api_request_type" = 0;
    text = "The wolf shirt strikes again!! #sdcc :P http://twitpic.com/blz4b";
    truncated = 0;
    user =         {
        "created_at" = "Sat Jul 25 20:34:33 +0000 2009";
        description = "Host of Tekzilla on Revision3 and Qore on PSN. Also, a geek.";
        "favourites_count" = 0;
        "followers_count" = 0;
        following = false;
        "friends_count" = 0;
        id = 5;
        location = "San Francisco";
        name = "Veronica Belmont";
        notifications = false;
        "profile_background_tile" = false;
        "profile_image_url" = "http://blabnow.com/avatar/Twitter_10350_new_twitter_normal.jpg";
        protected = 0;
        "screen_name" = Veronica;
        "statuses_count" = 2;
        "time_zone" = UTC;
        url = "http://www.veronicabelmont.com";
        "utc_offset" = 0;
    };

有人用这个可以告诉我其他人如何在他们的项目中使用它吗?

Anybody used this that can tell me how everyone else uses it in their project?

谢谢

推荐答案

您在控制台中看到的是NSDictionary的NSLog和不是NSString。来自Matt Gemmell的 MGTwitterEngine自述文件

What you are seeing in your console is an NSLog of an NSDictionary and not an NSString. From Matt Gemmell's MGTwitterEngine Readme:


发送到这些方法的值都是包含每个状态或用户或直接消息的NSDictionary的NSArrays,必要时带有子词典(例如,时间轴方法通常返回状态,每个它有一个子字典,提供有关发布该状态的用户的信息。)

The values sent to these methods are all NSArrays containing an NSDictionary for each status or user or direct message, with sub-dictionaries if necessary (for example, the timeline methods usually return statuses, each of which has a sub-dictionary giving information about the user who posted that status).

所以无论你传递给NSLog的对象是什么() statement实际上是一个字典,您可以通过调用来访问字段:

So whatever object you passed to your NSLog() statement is actually a dictionary and you can access the fields with a call to:

NSString *createdAtDate = [record valueForKey:@"created_at"];
NSString *source = [record valueForKey:@"source"];
// etc...

其中记录是宾语。请记住,用户字段是子字典。你这样访问它:

Where record is the object. Keep in mind that the user field is a sub-dictionary. You access it this way:

NSDictionary *userDict = [record valueForKey:@"user"];
NSString *name = [userDict valueForKey:@"name"];
NSString *location = [userDict valueForKey:@"location"];
// etc...

您实际上可以使用请求中返回的NSArray作为您的表视图的数据源,然后只需在-cellForRowAtIndexPath表视图委托中提取索引所需的数据源。

You could actually use the NSArray returned in the request as your table view's data source and then just extract the one you need by the index in your -cellForRowAtIndexPath table view delegate.

最好的问候,

这篇关于MGTwitterEngine和iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆