EventTimers are incredibly easier to setup. Create a dictionary in the page named EventTimers. You can add as many sub-dictionary timers, named anything you want. You can start and stop timers by referencing these names. The example to the right simply uses the names Timer1 and Timer2.
Each timer should have an Events dictionary. These events will get called at least once (if the timer is enabled), but the real power of timers is making them repeat at intervals using the following properties…
- Delay – a number value for the initial delay to wait before running the events. 1 would be a 1 second delay.
- Repeat – a number value for the amount of times the Timer will run the events again. 100 would run the Events 100 times.
- Frequency – a number value for the amount of time between repetitions. 1 would wait 1 second before running the events again.
- Enabled – a Bool value for whether or not the timer runs when the page loads. NO would turn it off initially.
You can start or stop the timer using the StartTimer or StopTimer events. The value would be the timer’s dictionary name. For example, in the image above one of the timers is simply named Timer1. These names are up to you.
If you stumbled onto this article, it is part of our documentation for the Story Tellers iOS Starter Kit 2. The kit enables you to make children’s book apps and games without writing any code! But it is Swift 2 based and compatible with iOS9 (or higher) and Xcode 7 (or higher), so kit buyers can even extend the functionality to fit their needs further. Some of what we cover in the kit documentation may apply to Xcode in general, so this article could be worth a read even if you aren’t a user. You can purchase Lifetime Updates the kit here, or subscribe Yearly to CartoonSmart and get the latest version, plus access to all of our other kits / tutorials.
We’ve also created an iBook to document the very latest properties in the kit, so be sure to download that as well.