Search code examples
xcodeswiftnstimercountdown

Count from 100 to 1 with a different interval


I'm trying to make a countdown in Swift which do not rely on any specific time, but a time interval i choose. For an example i want the countdown from 100-99 to take approximately 4 hours. Is that possible in any way?


Solution

  • You can use NSTimer to run a specific task after a given time and specify whether or not you want it to repeat itself. The method you're looking for is most likely scheduledTimerWithTimeInterval. For an example, please look at this post.

    For more informations, please look at Apple's NSTimer Class Reference and especially section titled Scheduling Timers in Run Loops.