看板 MacDev 關於我們 聯絡資訊
我想要程式按一個butten可以開始持續做某件事 按另一個butten可以結束這件事 可是我發現按了第一個butten之後我就不能按第二個了 我大概知道是因為我的程式架構有問題 可是我實在是想不出為什麼 我的code: /* myTest.m*/ #import "myTest.h" #import "periodicTest.h" @implementation myTest - (IBAction)startEvent:(id)sender{ [testOutlet doloop:YES]; } - (IBAction)stopEvent:(id)sender{ [textOutlet doloop:NO]; } @end ---------------------------------------------------------------------- /* periodicTest.m*/ #import "periodicTest.h" @implementation periodicTest - (void)doloop:(BOOL)R{ double resolution = 1.0; while (R) { NSDate* next = [NSDate dateWithTimeIntervalSinceNow:resolution]; [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:next]; printf("Do Loop...\n"); } } @end -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.161.148.99
Jerrynet:這可能要多一個執行緒@@ 05/05 19:33