In life, I cannot understand why this NSTimer will not shoot. here is all the code that seems relevant (at least for me)
- (IBAction)connectClick:(id)sender
{
if (connected)
{
NSLog(@"Disconnecting");
[timer invalidate];
timer = nil;
connected = NO;
[Connect setStringValue:@"Connect"];
NSLog(@"Finished\n");
}
else
{
NSLog(@"Connecting");
timer = [NSTimer timerWithTimeInterval:2.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
[Connect setStringValue:@"a"];
connected = YES;
NSLog(@"Finished\n");
}
}
- (void)timerFireMethod:(NSTimer*)theTimer
{
NSLog(@"Fireing event");
}
I read apple docs and other questions, but I can't figure it out. He doesn't even call timerDireMethod:once. I heard that this can be caused by different threads, but as far as I can tell, I do not use multiple threads.
Any ideas are welcome.
source
share