你能解释一下AppKit是否是线程安全的?我在哪里可以读到关于它的资料?( Threaded Programming Guide除外,因为本文档创建了更多问题而不是答案)。例如,我可以在独立线程中对NSToolbar执行validateVisibleItems操作吗?或者我可以在第二个线程中增加NSProgressIndicator的值吗?
发布于 2011-04-19 22:50:59
不,它不是一般的。你是should not send messages to any UI objects except from the main thread。
在您给出的特定示例中,您可以使用performSelectorOnMainThread:withObject:waitUntilDone:来绕过限制:
[myToolbar performSelectorOnMainThread: @selector(validateVisibleItems)
withObject: nil
waitUntilDone: whatever];https://stackoverflow.com/questions/5718304
复制相似问题