I have a function which takes a block as parameter:
typedef void (^ MyCallBack)(int);
-(void)doTask:(MyCallBack)callback{
...
}
I need to run the function in another thread with NSThread
:
NSThread* myThread = [[NSThread alloc] initWithTarget:self
selector:@selector(doTask:)
object:nil]; //how to pass callback block here?
[myThread start];
But how can I have the callback passed in the NSThread initialisation function above? Is it possible?
(If it is impossible, what could be the good alternative to achieve the same?)