How to I pass @selector as a parameter?

Posted by erotsppa on Stack Overflow See other posts from Stack Overflow or by erotsppa
Published on 2009-05-31T20:34:58Z Indexed on 2010/04/13 14:02 UTC
Read the original article Hit count: 481

Filed under:
|
|

For the method

[NSThread detachNewThreadSelector:@selector(method:) toTarget:self withObject:(id)SELECTOR];

How do I pass in a @selector? I tried casting it to (id) to make it compile but it crashes in runtime.


More specifically, I have a method like this

+(void)method1:(SEL)selector{
[NSThread detachNewThreadSelector:@selector(method2:) toTarget:self withObject:selector];

}

it crashes, how do I pass in the selector without crashing? So that the new thread can call the selector when the thread is ready?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone