开发者

NSTask or NSThread?

I have some code that is attached 开发者_如何学Goto 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜