Re: [問題] 請問Cocoa程式要如何一直做同件事情?

看板MacDev作者 (電腦無法阻止人類做蠢事)時間16年前 (2008/05/12 20:38), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串7/7 (看更多)
再補充一下NSRunLoop的使用時機: 1. Use ports or custom input sources to communicate with other threads. 2. Use timers on the thread. 3. Use any of the performSelector… methods in a Cocoa application. 4. Keep the thread around to perform periodic tasks. 摘自 http://0rz.tw/8745v (Threading Programming Guide) 基本上的原則就是,當你的Thread要做的工作, 有必要與別的thread做比較複雜的互動時,(例如,要在某個thread中動態增加工作) 就可以考慮使用NSRunLoop. 其他的情況,還是簡單一點,使用NSTimer與NSThread就好了。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.84.252.229
文章代碼(AID): #18A3egn9 (MacDev)
討論串 (同標題文章)
文章代碼(AID): #18A3egn9 (MacDev)