Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling private functions with NSTimer?

Is there a way to have an NSTimer call a private func when the timeout has expired?

(Does this even make sense? The NSTimer reference is local to the class, I'm not sure the caller's target at runtime is local, as well.)

like image 571
Joe Avatar asked Mar 16 '15 12:03

Joe


1 Answers

Yes, you just need to mark the function @objc:

 @objc private func runner(timer: NSTimer) {

Then it will respond to the selector, but be private to Swift.

like image 140
Rob Napier Avatar answered Nov 04 '22 23:11

Rob Napier