如何在后台使用 NSXMLParser

发布于 2025-01-03 23:48:05 字数 49 浏览 3 评论 0原文

我需要在后台模式下解析一些文件。我该怎么办呢。 NSXMLParser 是异步的吗?

I need to parse some files in the background mode. How can I do this. Is it NSXMLParser asynchronous?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

护你周全 2025-01-10 23:48:05

它不是异步的,但您始终可以使用以下命令在另一个线程中运行解析:

+ (void)detachNewThreadSelector:(SEL)aSelector toTarget:(id)aTarget withObject:(id)anArgument

It is not async, but you can always run the parse in another thread using this:

+ (void)detachNewThreadSelector:(SEL)aSelector toTarget:(id)aTarget withObject:(id)anArgument
墨落画卷 2025-01-10 23:48:05

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 :)

贱贱哒 2025-01-10 23:48:05

如果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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文