OK. I looked around, and didn't find an exact answer to my issue.
I am trying to test a timeout handler in a unit test (not the main run).
The issue seems to be that the [NSRunLoop mainRunLoop]
is not running in unit tests the way it does in the standard Run.
I do my timeouts in this manner:
NSTimer *pTimeoutHandler = [NSTimer
timerWithTimeInterval:2.0
target:self
selector:@selector(timeoutHandler:)
userInfo:nil
repeats:NO
];
[[NSRunLoop mainRunLoop] addTimer:pTimeoutHandler forMode:NSRunLoopCommonModes];
This works in the standard run. This is the recommended manner of setting a timeout.
However, in the Test run, this doesn't work. The timeoutHandler:(NSTimer*)timer
routine is never called.
It appears as if something is interfering with the run loop.
Is there any way for me to get the timeout to work in both run and unit test?