We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
您好,我运行Demo中的程序, 发现HWWeakTimer类的dealloc方法不会走,是不是说明有个HWWeakTimer对象不能被释放呢?
The text was updated successfully, but these errors were encountered:
如果将DetailViewController的dealloc中的[time invalidate]注释掉, HWWeakTimer的Fire方法会一直走, 并且HWWeakTimer对象的target现在持有的detailVC的指针(野指针)这很危险!!
Sorry, something went wrong.
经过测试发现,通过实例化对象传NSTimer的target和self传target这两种方式可能有所不同。
因为系统对target的引用方式是autorelease的,这个必须调用invalidate方法重置一下target,系统才会去释放那块内存,让引用停止,这就是重置target和将self变成弱引用都会造成循环引用的原因,可以用symbolic breakpoints进行查看。所以感觉重置代理的方式解决不了问题。
No branches or pull requests
您好,我运行Demo中的程序, 发现HWWeakTimer类的dealloc方法不会走,是不是说明有个HWWeakTimer对象不能被释放呢?
The text was updated successfully, but these errors were encountered: