Sending messages to object's delegates from another thread
I instantiate an object (let it be X), which has a delegate to be notified of error开发者_如何学运维s and successes in X's work.
I'm doing all repetitive routine work in a secondary thread which X's delegate is not aware of - actually, he doesn't care if there is a secondary thread or not.
Is there any difference in how to dispatch messages to delegate - should I send them from within the secondary thread or use [performSelectorOnMainThread]
?
It depends on what your delegate does. If it's something with UI or OpenGL, then you should do it on the main thread ;)
This is not the complete list but if you are using this objects is ok to do it in the background:
http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html%23//apple_ref/doc/uid/10000057i-CH12-SW1
精彩评论