gpt4 book ai didi

ios - Twitter 趋势 API 1.1 错误 "unrecognized selector sent to instance"

转载 作者:行者123 更新时间:2023-11-29 03:41:05 27 4
gpt4 key购买 nike

看看下面我的代码:

NSError *jsonParsingError;
NSDictionary *jsonResults = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonParsingError];
NSArray *trends = jsonResults[@"trends"]; //error on this line

我遇到“无法识别的选择器发送到实例”错误。

我使用的网址是:https://api.twitter.com/1.1/trends/place.json?id=1

查看 jsonResults 值:

Take a look at the jsonResults value

与 TwitterSearch(示例应用程序)结果相比:

Compared to the TwitterSearch results

这是 jsonResults 变量的记录值:

2013-08-26 11:05:44.489 TwitterTrends[48410:490b] JSON: (
{
"as_of" = "2013-08-26T03:04:24Z";
"created_at" = "2013-08-26T02:51:26Z";
locations = (
{
name = Worldwide;
woeid = 1;
}
);
trends = (
{
events = "<null>";
name = "#chupaedu";
"promoted_content" = "<null>";
query = "%23chupaedu";
url = "http://twitter.com/search?q=%23chupaedu";
},
{
events = "<null>";
name = "#VMA2013NAMTV";
"promoted_content" = "<null>";
query = "%23VMA2013NAMTV";
url = "http://twitter.com/search?q=%23VMA2013NAMTV";
},
{
events = "<null>";
name = "#YoConfiesoQue";
"promoted_content" = "<null>";
query = "%23YoConfiesoQue";
url = "http://twitter.com/search?q=%23YoConfiesoQue";
},
{
events = "<null>";
name = "#MiObsesionPor";
"promoted_content" = "<null>";
query = "%23MiObsesionPor";
url = "http://twitter.com/search?q=%23MiObsesionPor";
},
{
events = "<null>";
name = "#LasMejoresPeliculasQueViFueron";
"promoted_content" = "<null>";
query = "%23LasMejoresPeliculasQueViFueron";
url = "http://twitter.com/search?q=%23LasMejoresPeliculasQueViFueron";
},
{
events = "<null>";
name = "Emile Sande";
"promoted_content" = "<null>";
query = "%22Emile+Sande%22";
url = "http://twitter.com/search?q=%22Emile+Sande%22";
},
{
events = "<null>";
name = "Daniel Furlan";
"promoted_content" = "<null>";
query = "%22Daniel+Furlan%22";
url = "http://twitter.com/search?q=%22Daniel+Furlan%22";
},
{
events = "<null>";
name = JHud;
"promoted_content" = "<null>";
query = JHud;
url = "http://twitter.com/search?q=JHud";
},
{
events = "<null>";
name = "Omg Adam Lambert";
"promoted_content" = "<null>";
query = "%22Omg+Adam+Lambert%22";
url = "http://twitter.com/search?q=%22Omg+Adam+Lambert%22";
},
{
events = "<null>";
name = "Macklemore & Ryan Lewis";
"promoted_content" = "<null>";
query = "%22Macklemore+%26+Ryan+Lewis%22";
url = "http://twitter.com/search?q=%22Macklemore+%26+Ryan+Lewis%22";
}
);
}
)

最佳答案

如 H2CO3 所示,返回的是一个数组,而不是一个字典。我将代码修改为:

NSArray *jsonResults = [NSJSONSerialization JSONObjectWithData:responseData 选项:0 错误:&jsonParsingError];

关于ios - Twitter 趋势 API 1.1 错误 "unrecognized selector sent to instance",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18436082/

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