Zeroing Weak References in ARC

偶尔善良 提交于 2019-11-26 11:06:00

问题


If my reading of Mike Ash\'s \"Zeroing Weak References\" writeup is correct, weak references are like assign references without ARC. However, if the referenced object is deallocated, instead of getting a \"dangling pointer\" (meaning a pointer that points to a deallocated object), the pointer gets set to nil.

Is this right, and does this happen with any property marked weak or assign (when ARC is active)?

If this is correct, this would eliminate a lot of SIGABRTs.


回答1:


It's mostly right, but assign properties are still treated the same as they ever were, only weak ones are zeroing. Another caveat is that zeroing weak references are only available in Mac OS X ≥ 10.7 and iOS ≥ 5. While the rest of ARC was backported to 10.6 and iOS 4, weak references cannot be used at all on these OS's.



来源:https://stackoverflow.com/questions/7246513/zeroing-weak-references-in-arc

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