I make a JSON request with AFNetworking and then call [operation waitUntilFinished] to wait for the operation and success or failure blocks. But it seems to be true, but in the log messages I get "0", "3", "1" instead of "0", "1", "3"
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://google.com"]]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; httpClient.parameterEncoding = AFFormURLParameterEncoding; NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"query", @"q", nil]; NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET" path:[url path] parameters:params]; NSLog(@"0"); AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *innerRequest, NSHTTPURLResponse *response, id JSON) { NSLog(@"1"); gotResponse = YES; } failure:^(NSURLRequest *innerRequest, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"2"); gotResponse = YES; }]; NSLog(@"Starting request"); [operation start]; [operation waitUntilFinished]; NSLog(@"3");
Kamran
source share