NSTimer does not fire selector in Objective C

109 Views Asked by At

I am trying to use a timer to fire the onTick method once after a 0.5 second delay using the following Objective C code in Xcode for a MacOS target

[NSTimer scheduledTimerWithTimeInterval:0.5
        target: self
        selector:@selector(onTick:)
        userInfo:nil repeats:NO];
    
    ...
    
    -(void) onTick
    {
        
    }

But the selector onTick never fires. The code is in AppDelegate.m and is running on the main thread. What am I doing wrong?

1

There are 1 best solutions below

0
matt On BEST ANSWER

Change

@selector(onTick:)

to

@selector(onTick)

(notice the deleted colon).