0
如何使用performSelector:onThread:withObject:waitUntilDone:?在onthread中,我必须使用其他线程而不是主线程。如何创建其他线程?给我一些示例代码。如何使用performSelector:
如何使用performSelector:onThread:withObject:waitUntilDone:?在onthread中,我必须使用其他线程而不是主线程。如何创建其他线程?给我一些示例代码。如何使用performSelector:
除非你有一个线程池来管理,它更容易使用-performSelectorInBackground:…
:
[object performSelectorInBackground:@selector(method:) withObject:foo];
如果你要创建一个线程,使用
NSThread* thread = [[NSThread alloc] init];
[object performSelector:@selector(method:)
onThread:thread
withObject:foo
waitUntilDone:YES];
[thread release];
感谢您的回复。但这不起作用。方法没有调用。 – Allen 2010-05-13 12:40:59
@艾伦:你的代码是什么? – kennytm 2010-05-13 13:38:30
您好Kenny,您需要在目标线程中运行一个运行循环,以便处理'performSelector:'输入源。所以我不认为你的代码工作... – Yuji 2010-05-13 15:25:30