如果我阅读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中归零弱参考
发布评论