gpt4 book ai didi

iphone - MGTwitterEngine 和 iPhone

转载 作者:行者123 更新时间:2023-12-03 20:24:54 25 4
gpt4 key购买 nike

我下载了 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;
};

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

谢谢

最佳答案

您在控制台中看到的是 NSDictionary 的 NSLog,而不是 NSString。来自马特·格梅尔的MGTwitterEngine Readme :

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() 语句的任何对象实际上都是一个字典,您可以通过调用来访问这些字段:

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

其中记录是对象。请记住,user 字段是一个子字典。您可以通过以下方式访问它:

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

您实际上可以使用请求中返回的 NSArray 作为 TableView 的数据源,然后只需通过 -cellForRowAtIndexPath TableView 委托(delegate)中的索引提取所需的数据源。

最诚挚的问候,

关于iphone - MGTwitterEngine 和 iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1197996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com