关于Timer
Timers work in conjunction with run loops. Run loops maintain strong references to their timers, so you don’t have to maintain your own strong reference to a timer after you have added it to a run loop.
在主线程中可能由于强引用造成Timer无法释放,引起内存泄漏。
还有一种情况,就是self强引用Timer,Timer又强引用self,导致无法执行dealloc方法。
1、其中有一种解决方法,使用NSProxy
- 使用弱引用
weak - (id)forwardingTargetForSelector:(SEL)aSelector
2、使用block写一分类解决