目标C中的代表仅在特定线程上

时间:2010-09-28 02:39:23

标签: objective-c delegates

我有两个线程主线程和工作线程。我希望能够做的是将回调(委托)安排到工作线程,而不管谁调用触发这些代理的函数。例如:

/* mainThread */
[Obj asyncCallback]; // triggers callback to delegate foo()

/* Worker thread should do all the callback processing. i.e when foo() is called [NSThread currentThread] should always give worker threads ID and never main threads ID. */

1 个答案:

答案 0 :(得分:0)

最简单的选择可能是-performSelector:onThread:waitUntilDone:。您需要确保您的工作线程启动run loop