Repeating Timer in Swift

Creating a repeating timer is simple with the following code.

  • timerInterval denotes the number of seconds between the firings of timer.
  • target denotes the object to which send a message specified by selector.
  • selector denotes the message to sent to the target after the timer gets fired.
  • UserInfo can be used to send additional information about timer event in a dictionary format.
  • repeats denotes whether a timer is repeating or non-repeating. If it is set to true, the timer reschedules itself after getting fired automatically until it is manually invalidated and if it is set to false, the timer fires once and gets invalidated automatically.

 

Leave a Reply