views:

88

answers:

1

I have some code that is attached to an NSTimer. Around 5 times every second, it interacts with another application (by emulating keystrokes) and when appropriate spits out an NSNotification, that is handled by another piece of code.

While the timer code is running, the UI is unresponsive, so I can't include a 'stop' button that halts the timer.

How should I handle this? A separate process (NSTask right?) or thread? Remember that at unpredictable times, the timer code will need to send some info back for processing.

Thanks.

+2  A: 

Run it in a separate thread. It can report back to the UI occasionally with the performSelectorOnMainThread: method.

Marcelo Cantos