开发者

How to parse xml without freezing GUI in iphone SDK?

How to parse xml without freezing GUI in iphone SDK ?

du开发者_StackOverflow社区ring 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜