I'm calling one method from another method.The method exits in the middile. After completing some tasks, it will run the remaining method.
-(void)stateMethod{
[self.pickerView selectRow:0 inComponent:0 animated:YES];
lblTitle.text=@"State";
self.stateTF.text=@"";
self.stateTF.inputView=_pickerView;
[self.stateTF setInputAccessoryView:toolBar];
NSString * method=@"***************************?countryID=";
NSString *urlString=[NSString stringWithFormat:@"%@%@%@",MAIN_URL,method,_countryId];
NSURL *url_ac=[[NSURL alloc]initWithString:urlString];
NSMutableURLRequest *request_ac=[[NSMutableURLRequest alloc]initWithURL:url_ac];
[request_ac setValue:loginUser.acessTokenStr forHTTPHeaderField:@"access_token"];
[NSURLConnection sendAsynchronousRequest:request_ac queue:[NSOperationQueue currentQueue] completionHandler:
^(NSURLResponse ac_response, NSData acData, NSError *connectionError) {
if (connectionError)
{
NSLog(@"ERROR CONNECTING DATA FROM SERVER: %@", connectionError.localizedDescription);
}
else {
dispatch_async(dispatch_get_main_queue(), ^{
NSString *responseString = [[NSString alloc] initWithData:acData encoding:NSUTF8StringEncoding];
[self parseStateListResult:acData];
});
}
}];
}
I want the response when i'm calling the state method. Based on state method response,i'm executing one task after calling [self statemethod]. That task need 'state methodresponce. That task is executing before getting the data from state method.
The method exits after
NSURLConnection` line. I want to run the method asynchronously. Please help me.