我想获得带有特定主题标签的推文。我使用 Twitter 搜索 URL。这是我的代码:
NSMutableString *urlString = [NSMutableString stringWithFormat:@"%s","http://search.twitter.com/search.json?q=%23zesdaagsegent"];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
NSLog(@"%@", data);
NSError *error;
NSMutableArray *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"%@", json);
NSMutableArray *results =[NSMutableArray array];
for(NSDictionary *item in json)
{
[results addObject:[item objectForKey:@"results"]];
}
我的 NSLog 得到了我需要的输出:
2013-05-28 09:48:45.080 ZesdaagseGent [572:11303] { "completed_in" = "0.023"; "max_id" = 339031661368975360; “max_id_str”=339031661368975360;页 = 1; 查询 = "%23zesdaagsegent"; "refresh_url" = "?since_id=339031661368975360&q=%23zesdaagsegent"; 结果 = ( { "created_at" = "Mon, 27 May 2013 14:53:41 +0000"; "from_user" = SigfridMaenhout; "from_user_id" = 369194526; "from_user_id_str" = 369194526; "from_user_name" = "Sigfrid Maenhout";地理=“”;id=339031661368975360;“id_str”=339031661368975360;"iso_language_code" = nl; 元数据 = { "result_type" = 最近; }; 来源 = "<a href="http://twitter.com/ ">网络</a> ;"; text = "#zesdaagsegent Het is een zonnige dag hier in Merelbeke. We verlangen allemaal naar een beetje zonnestralen in het gezicht, toch?"; }); “results_per_page”=15;"since_id" = 0; "since_id_str" = 0; }
我需要包含对象的数组“结果”。我的问题是我无法使用 objectForKey 方法在 NSMutableArray 中获得结果。
有人有想法吗?