0
AFJSONRequestOperation
을 사용하여 기상 데이터를 가져 오려고합니다. 문제는 쿼리가 완료 될 때 개체를 반환 할 수 없다는 것입니다. 그걸하는 법을 아는 사람이 있습니까?AFJSONRequestOperation을 사용하여 응답 개체를 반환하는 방법
나의 현재 implemation는 의미에서,이 작업을 수행 할 수있는 방법이 있습니다
- (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];
}
확인이 다른 질문 http://stackoverflow.com/questions/7969865/can- 여기
내 코드의 일부에서 예입니다 afnetworking-return-data-synchronous-inside-a-block – tkanzakic