如何在后台使用 NSXMLParser
我需要在后台模式下解析一些文件。我该怎么办呢。 NSXMLParser 是异步的吗?
I need to parse some files in the background mode. How can I do this. Is it NSXMLParser asynchronous?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它不是异步的,但您始终可以使用以下命令在另一个线程中运行解析:
It is not async, but you can always run the parse in another thread using this:
您可以使用 GCD 调度队列或操作队列在后台运行解析。
https://developer.apple.com/ Library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
块很有趣:)
You could use GCD dispatch queues or Operation Queues to run the parsing in the background.
https://developer.apple.com/library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Blocks are fun :)
如果ios是4.0+,那么你可以将 NSXMLParser 放在另一个类中,并使该类成为当前视图控制器的委托。它将在不同的线程上运行,并且不会阻塞您的主线程。
If ios is 4.0+, then you can put NSXMLParser in another class and make the class to be the delegate of your current view controller. It will run at different thread and won't block your main thread.