How to parse xml without freezing GUI in iphone SDK ?
during parsing user can interact with gui components. But as i have seen most of the times GUI become freeze when xml parsing performed.
How to parse xml without freezing GUI in iphone SDK ?
during parsing user can interact with gui components. But as i have seen most of the times GUI become freeze when xml parsing performed.
Move parsing to the background thread, the easiest way will be to call:
[someObject performSelectorInBackground:@selector(parse) withObject:nil];
Remember that each thread requires separate NSAutoreleasePool for proper memory management so you will need to create it in the beginning of the parse method and drain in the end:
- (void) parse{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
...
[pool drain];
}
Just as Vladimir mentioned, the background thread is the way to go. Check out the Apple sample code called SeismicXML as it does full asynch XML parsing with the NSXMLParser.