In my "didFinishLaunchingWithOptions" method, I have created a UIProgressView in my GUI & after that I call a method to call a WebService with a NSURLConnection to get an XML with a SOAP message.
In the delegate method "connectionDidFinishLoading" I parse the XML with NSXMLParser in another class.
The problem is that I want to update my UIProgressView while the XML is parsed, but it is updated after the whole XML has been parsed. I have heard this is because the NSURLconnection run on the main thread and is blocking the UI.
How can I parse and update the progress bar in the same time ?
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString * theXML = [[NSString alloc] initWithBytes:[webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSLog( @"The XML : %@", theXML );
[theXML release];
theXmlParser = [[NSXMLParser alloc] initWithData:webData];
XMLParser * theParseur = [[XMLParser alloc] initXMLParser];
[theXmlParser setDelegate:theParseur];
[theXmlParser setShouldProcessNamespaces:NO];
[theXmlParser setShouldReportNamespacePrefixes:NO];
[theXmlParser setShouldResolveExternalEntities:NO];
NSLog(@"Begin parsing...");
BOOL success = [theXmlParser parse];
if( success ) {
// my code...
} else {
NSLog(@"XML partner : End Parsing > ERROR : %@", [[theXmlParser parserError] localizedDescription] );
[theXmlParser release];
}
[connection release];
[webData release];
}