Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems using NSXMLParser asynchronously
    primarykey
    data
    text
    <p>I have been developing an app for iPad and consuming the Web Service in it. Everything is working fine except that NSXMLParser is not working asynchronously.</p> <p>I am getting the data from web service and feeding it to NSXMLParser like this</p> <pre><code> xmlParser = [[NSXMLParser alloc] initWithData: webData]; [xmlParser setDelegate: self]; [xmlParser setShouldResolveExternalEntities:YES]; [xmlParser parse]; </code></pre> <p>I am implementing parser delegate methods didStartElement, foundCharacters and didEndElement. Here is my didEndElement method</p> <pre><code>-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { NSLog(@"did end element"); if ([elementName isEqualToString:@"authorizePassengerByEmailResult"]) { NSLog(@"Inside Parser didEnd, CheckNo: %d",checkNo); NSLog(@"Soap Results: %@", soapResults); checkNo = 3; [soapResults setString:@""]; elementFound = FALSE; } } </code></pre> <p>In above method checkNo is a global variable which i am using to check whether its value is changing or not in didEndElement.</p> <p>In my viewController this is how i am calling the stuff</p> <pre><code>- (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == txtEmail) { [txtPwd becomeFirstResponder]; } if (textField == txtPwd) { [textField resignFirstResponder]; [self.activityIndicator startAnimating]; [self startWebServiceOperations]; [self onLoginButtonClicked]; } return YES; } </code></pre> <p>Here are the other two mthods</p> <pre><code>- (void)onLoginButtonClicked { [self.activityIndicator stopAnimating]; if ([results isEqualToString:@"Not Authorized"]) { } else { NSLog(@"Should be 3 but Checkno:%d",checkNo); } } - (void)startWebServiceOperations { NSLog(@"I m here, Hello"); NSString *serviceURL = @"URLAddress"; webServices = [[WebServices alloc] init]; NSString *strEmail = [NSString stringWithFormat:@"%@",txtEmail.text]; NSString *strPassword = [NSString stringWithFormat:@"%@",txtPwd.text]; [webServices createRequest:serviceURL methodNameis:@"authorizePassengerByEmail" firstParameter:strEmail secondParameter:strPassword]; } </code></pre> <p>Now the problem is i want to finish up the whole web service process and the NSXMLParser methods and then move to next function. In other words i want startWebServiceOperations function to finish completely and then move to onLoginButtonClicked function.</p> <p>If i see the global variable checkNo it shows output 1 instead of 3.</p> <p>Any help would be highly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload