MGTwitterEngine和iPhone

Xco*_*der 2 iphone twitter objective-c mgtwitterengine

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

      {
    "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;
    };
Run Code Online (Sandbox Code Playgroud)

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

谢谢

Mat*_*ong 8

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

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

因此,无论您传递给NSLog()语句的对象实际上是一个字典,您都可以通过以下方式访问字段:

NSString *createdAtDate = [record valueForKey:@"created_at"];
NSString *source = [record valueForKey:@"source"];
// etc...
Run Code Online (Sandbox Code Playgroud)

其中记录是对象.请记住,用户字段是子字典.你这样访问它:

NSDictionary *userDict = [record valueForKey:@"user"];
NSString *name = [userDict valueForKey:@"name"];
NSString *location = [userDict valueForKey:@"location"];
// etc...
Run Code Online (Sandbox Code Playgroud)

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

最好的祝福,