在ARC中归零弱参考

编程入门 行业动态 更新时间:2024-10-18 03:30:36
本文介绍了在ARC中归零弱参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我阅读Mike Ash的Zeroing Weak Referenceswriteup 是正确的,弱引用就像 assign 没有ARC的引用。然而,如果被引用的对象被释放,而不是获得悬挂指针(意味着指向被释放对象的指针),则指针被设置为 nil 。

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.

这是正确的,标记为 weak 或 assign (当ARC处于活动状态时)

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

如果这是正确的,这将消除很多SIGABRT。 p>

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

推荐答案

这是正确的,但 assign 属性仍然被视为相同曾经,只有 weak 的是归零。另一个警告是,归零弱引用仅适用于Mac OS X≥10.7和iOS≥5.其余的ARC反向移植到10.6和iOS 4,弱引用根本不能在这些操作系统上使用。

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.

更多推荐

在ARC中归零弱参考

本文发布于:2023-11-13 02:14:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583135.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ARC   中归零弱

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!