Invalidating an NSTimer in dealloc

非 Y 不嫁゛ 提交于 2019-12-03 17:17:02
ogres

ARC will only release ( and call dealloc ) objects, when there are no strong references pointing to this object ( no one is retaining ).

NSTimer creates strong reference and it will retain target.

This means, dealloc will not be called, because NSTimer still has strong reference to the object. If there is no dealloc, this means NSTimer will never be invalidated ... leads to memory leak or even crashes.

There is a way to invalidate timer in dealloc or when target becomes nil. Have a look at the answer here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!