Question

There is a NSCollectionView in my Mac application, and it contains some icons. Meanwhile, I am using NSOperationQueue as a task scheduler to queue some operations. In one NSOperation, I modify the Content of NSCollectionView, the view should update at once when Content changes.

If I update it in the main thread, then it works perfectly well. If I put the same source code at the end of the NSOperation::main(), then the NSCollectionView would be completely blank.

Is this some kind of bug or I do it in the wrong way?

Thanks!

Était-ce utile?

La solution

All interaction with UI elements must be performed on the main thread.

You can use the performSelectorOnMainThread:withObject:waitUntilDone: method to help you update UI elements from background threads.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top