我在這裏做錯了什麼?我錯過了什麼?Custom RunLoop模式
- (void)scheduleTimer
{
NSTimer *timer = [NSTimer timerWithTimeInterval:0.15
target:self
selector:@selector(wtf:)
userInfo:nil
repeats:NO];
// This works fine
// [[NSRunLoop currentRunLoop] addTimer:timer
// forMode:NSDefaultRunLoopMode];
// This doesn't work at all - how come?
[[NSRunLoop currentRunLoop] addTimer:timer
forMode:@"MyCustomRunLoopMode"];
}
- (void)wtf:(NSTimer *)aTimer
{
NSLog(@"wtf");
}
NSRunLoop的文檔似乎表明可以創建自定義runloop模式。我錯過了什麼嗎?
(這是在Mac OS X標準的GUI應用程序的主線程)
更新:我提到這個通知是一個標準的應用程序的主線程上。因此,我沒有自己運行runloop。這一切都由NSApplication處理。