How to use performSelector:onThread:withObject:waitUntilDone:? here in onthread i have to use other thread not main thread. How to create other thread? give me some sample code.
+2
A:
Unless you have a thread pool to manage, it's easier to use -performSelectorInBackground:…
:
[object performSelectorInBackground:@selector(method:) withObject:foo];
If you're going to create a thread, use
NSThread* thread = [[NSThread alloc] init];
[object performSelector:@selector(method:)
onThread:thread
withObject:foo
waitUntilDone:YES];
[thread release];
KennyTM
2010-05-13 12:23:05
thanks for your reply. but this is not working. method not calling.
Allen
2010-05-13 12:40:59
@Allen: What's your code?
KennyTM
2010-05-13 13:38:30
Hi Kenny, you need to run a run-loop in the target thread so that the `performSelector:` input source is dealt with. So I don't think your code to work...
Yuji
2010-05-13 15:25:30
@Kenny TM: your answer works perfectly. Thanks. I don't know why the poster couldn't get it to work and never accepted your answer, but it is correct. Thanks.
Digital Robot
2010-08-06 11:05:50