开发者

Is it possible to use NSThreads for parsing four different URLs using NSXMLParser

If I try to parse single HTTP URL, it will be done quic开发者_如何学编程kly. But if I have to parse four different URLs at application launch, is it feasible to use NSThreads and NSOperation queue. Can any one explain with a small example if possible?

Sagos


Write an NSOperation subclass, and in the main method, do something like this:

- (void)main
{
    NSXMLParser *parser = [[[NSXMLParser alloc] initWithContentsOfURL:myURL_] autorelease];
    [parser setDelegate:self];
    [parser parse];
}

Implement your parser delegate methods on your NSOperation subclass. Then instantiate the subclasses, assign them the URLS, and add them to an operation queue. Use notifications or delegates to know when they are finished.


Yes. Do use NSOperationQueue. The following link basically shows how to parse multiple URL (xml files) using NSOperationQueue.

http://www.cocoabuilder.com/archive/cocoa/275115-nsoperationqueue-for-nsxmlparser-object.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜