我正在尝试通过使用获取天气数据AFJSONRequestOperation
。问题是查询完成后我无法返回对象。有谁知道该怎么做?
我目前的实现是
- (NSDictionary *)getCityWeatherData:(NSString*)city
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://free.worldweatheronline.com/feed/weather.ashx?key=xxxxxxxxxxxxx&num_of_days=3&format=json&q=%@", city]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSDictionary *data = [[JSON objectForKey:@"data"] objectForKey:@"weather"];
return data;
} failure:nil];
[operation start];
}