NSTimer provides an easy to use timer API, but issues arise when working with GCD.
Here’s an NSTimer replacement from Javier Soto of Mindsnacks that provides a nice simple syntax like NSTimer but doesn’t retain the target, and can be used by GCD queues thus removing the need for you to work directly with dispatch_source when you need timers for a GCD thread.
As the readme states:
The first motivation for this class was to have a type of timer that objects could own and retain, without this creating a retain cycle ( like NSTimer causes, since it retains its target ). This way you can just release the timer in the -dealloc method of the object class that owns the timer.
and..
More often than not, an object needs to create a timer and invalidate it when a certain event occurs. However, doing this when that object works with a private GCD queue gets tricky. This timer object is thread safe and doesn’t have the notion of run loop, so it can be used with GCD queues and installed / invalidated from any thread or queue.
You can find NSWeakTimer on Github here.
A nice easy timer class that works with GCD.
- iPhone Objective-C Programming NSTimer
- Open Source Drop In UILabel Replacement Library For Easy Fancy Text With Gradients and Shadows
- Tutorial: Using The Message Center In The Open Source Innerband (iBoost) Library
- Open Source: Massive Collection Of Objective-C Blocks Extensions
- Open Source Control Providing A Highly Customizable Image Based UISwitch Replacement
Original article: iOS Library Providing An NSTimer Replacement That Supports GCD Queues
©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.





