I have a NSThread that i would like to timeout after a certain amount of time.
[NSThread detachNewThreadSelector:@selector(someFuntion) toTarget:self withObject:nil];
- (void) someFunction {
//Some calculation that might take a long time.
//if it takes more then 10 seconds i want it to end and display a error message
}
Any help you can provide on this would be greatly appreciated.
Thanks,
Zen_silence
Try something like this:
Be sure that you (1) check
workerThread.isCancelledwhen the thread finishes to see whether the thread timed out, and (2) call[timoutTimer invalidate]to clean up the timer if the thread did not time out.