Reputation: 3258
What am I doing wrong here? What am I missing?
- (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");
}
The documentation for NSRunLoop seems to indicate one can create custom runloop modes. Am I missing something?
(This is on the main thread of a standard GUI application in Mac OS X)
Update: Notice that I mentioned this was on the main thread of a standard application. Therefore, I'm not running the runloop myself. It's all being handled by NSApplication.
Upvotes: 0
Views: 1679
Reputation: 7200
Could it be that the currentRunLoop only runs in common modes?
You should also try: - (BOOL)runMode:(NSString *)mode beforeDate:(NSDate *)limitDate
and check things out with: - (NSString *)currentMode
--Tom
Upvotes: 1
Reputation: 237080
Are you running the runloop for that mode? Just adding a timer won't do anything if the runloop never runs in that mode.
Upvotes: 5