Objective c NSTimer未在目标C中触发选择器
我正在尝试使用一个计时器在0.5秒延迟后触发onTick方法,在MacOS目标的Xcode中使用以下目标C代码Objective c NSTimer未在目标C中触发选择器,objective-c,macos,nstimer,Objective C,Macos,Nstimer,我正在尝试使用一个计时器在0.5秒延迟后触发onTick方法,在MacOS目标的Xcode中使用以下目标C代码 [NSTimer scheduledTimerWithTimeInterval:0.5 target: self selector:@selector(onTick:) userInfo:nil repeats:NO]; ... -(void) onTick { }
[NSTimer scheduledTimerWithTimeInterval:0.5
target: self
selector:@selector(onTick:)
userInfo:nil repeats:NO];
...
-(void) onTick
{
}
但选择器onTick从不开火。代码位于AppDelegate.m中,并在主线程上运行。我做错了什么?改变
@selector(onTick:)
到
(注意删除的冒号)
@selector(onTick)