ondalabs/OLImageView — pull request #8 by ejensen (2013-03-30 07:05:09+00:00)
Title: Replace NSTimer with CADisplayLink

First off, I'd like to thank you for creating this useful library! :smiley:

Now, on to the pull request....

The primary change in this pull request is to the way OLImageView creates its animation loop. Instead of using a NSTimer with a 0.005 sec interval, it now uses a [CADisplayLink ](http://developer.apple.com/library/ios/#documentation/QuartzCore/Reference/CADisplayLink_ClassRef/Reference/Reference.html) to coordinate animation updates with display refreshes.

Switching to CADisplayLink cuts the demos CPU usage in half!
I've attached some profiling results below :point_down:

#### iPhone 5 CPU usage ####
* NSTimer: 10 - 14%
* CADisplayLink: 3 - 7%

![NSTimer_iPhone_5](https://f.cloud.github.com/assets/915431/319954/1d7699b4-9900-11e2-8166-dbcf997f1ce5.png)
![CADisplayLink_iPhone_5](https://f.cloud.github.com/assets/915431/319957/21bd3eec-9900-11e2-9c87-a07312cf4bd9.png)

#### iPhone 4 CPU usage ####
* NSTimer 19 - 30%
* CADisplayLink: 6 - 11%

![NSTimer_iPhone_4](https://f.cloud.github.com/assets/915431/319962/0d65c210-9901-11e2-93ac-101f31a9ed01.png)
![CADisplayLink_iPhone_4](https://f.cloud.github.com/assets/915431/319958/21bb8aa2-9900-11e2-9ba5-3de6473d1ca8.png)

This pull request also makes changes to the animation's runloop configuration. Some people like the animations to pause while scrolling, others don't, so I thought: Why not make it configurable? OLImageView.runLoopMode is now available for setting that option.

Let me know if you have any questions. I know this is a large changeset to go through.
-Eric