I'm trying to get weather data by using AFJSONRequestOperation
. The problem is I can't return the object when the query is done. Is there anyone know how to do that?
My current implemation is
- (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];
}