Book Image

Application Development in iOS 7

By : Kyle Begeman
Book Image

Application Development in iOS 7

By: Kyle Begeman

Overview of this book

Table of Contents (15 chapters)
Application Development in iOS 7
About the Author
About the Reviewers


It is a common practice to perform periodic tasks using NSTimer. The following is an example use of NSTimer to perform a task in two-second intervals and repeats:

[NSTimer scheduledTimerWithTimeInterval:2.0

The issue with this method is that the CPU is consistently active in order to perform the desired task repeatedly. When using multiple timers at once, it is possible (although unlikely) that it may reduce the performance of the CPU for the rest of your application. It is always best practice to run tests on your applications to find such possibilities and use safeguards wherever possible.

Apple has added a new tolerance property to NSTimer to reduce the strain on the CPU when using NSTimers. This property will tell the application how late a timer is allowed to fire when it has surpassed its scheduled interval. As a result, the application will be able to group actions together to reduce CPU strain.