作者Dannier (猫尾巴~)
看板MacDev
标题[问题] 请问Cocoa程式要如何一直做同件事情?
时间Mon May 5 18:22:07 2008
我想要程式按一个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
1F:推 Jerrynet:这可能要多一个执行绪@@ 05/05 19:33