看看我下面的代码:
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 的值:
与 TwitterSearch(一个示例应用程序)结果相比:
这是 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";
}
);
}
)