1
AFNetworking과 협력하여 웹에서 일부 JSON을 얻으려고합니다. 반환 된 비동기 요청의 응답을 어떻게 얻을 수 있습니까? 내 코드는 다음과 같습니다.AFJSONRequestOperation이 완료되기를 기다리는 중
- (id) descargarEncuestasParaCliente:(NSString *)id_client{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://whatever.com/api/&id_cliente=%@", id_client]]];
__block id RESPONSE;
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
RESPONSE = JSON;
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"ERROR: %@", error);
}];
[operation start];
return RESPONSE;
}
덕분에 다음과 같은 예를 들어
것은
당신은이 메소드를 호출합니다! 그러나 함수의 반환 형식이 void로 변경되지 않습니까?이 경우에는? –
당신은 절대적으로 맞습니다 –
나는 그렇게 생각했습니다. 귀하의 구현은 실제로 효과가있었습니다. 고마워요! :) –