How to create an NSTimer

Timers are good if you want to delay executing a method, or if you need to call a method repeatedly. To set a one-off timer without setting a property you can use this:

However, you won’t be able to stop it without a reference. This is fine for one-off timers, but you need one if you want to stop a repeating timer.

To start a repeating timer self.myTimer:

And to stop if:

Here’s a working example on GitHub: https://github.com/versluis/TimerFun

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.