在同一应用程序中运行 AQXMLParser 和 NSXMLParser
我试图在后台线程中运行 AQXMLParser 的实例,同时还在独立线程上运行 NSXMLParser 的实例。但是,如果在 AQXMLParser 尚未完成解析时启动 NSXMLParser,则应用程序会在 xmlparsechunk 方法处崩溃。
我已经尝试了从 GCD 到 PerformSelectorinBackground 的所有方法。
唯一不会发生这种崩溃的情况是当我在主线程上运行它们中的任何一个时。
我一直在努力解决这个问题,但还没有任何运气。
非常感谢任何建议。
I am trying to run an instance of AQXMLParser in the background thread while also running an instance of NSXMLParser on an independent thread. However, if the NSXMLParser is started while the AQXMLParser has not completed parsing, then the app crashes at the xmlparsechunk method.
I've tried everything from GCD to performSelectorinBackground.
The only time this crash doesn't happen is when I run either of them on the main thread.
I've been working real hard to resolve the issue, but haven't had any luck yet.
Any advice is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过使用 NSLock 包装代码的关键区域(始终发生崩溃的地方)?这样,只有当其他进程没有使用该特定部分时,每个进程才能访问该部分。
Have you considered wrapping the critical area of code (where the crash consistently occurs) with an NSLock? That way, each process can access that specific section only if the other is not using it.