在主线程上运行 NSOperation
我构建了一个 NSOperation 在后台线程上运行,但此后我优化了该操作,这样我可能更适合在主线程中运行它。有没有办法指导我的 NSOperation 在主线程而不是后台线程上运行,以便我可以在不进行重大重构的情况下进行测试?
I built a NSOperation to run on a background thread, but I have since optimized the operation such that I might be better suited running it in the main thread. Is there a way to direct my NSOperation to run on the main thread instead of a background thread so that I can test things out without significant refactoring?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
mainQueue
在NSOperationQueue
中执行此操作http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html
You can do this in the
NSOperationQueue
by usingmainQueue
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html