gpt4 book ai didi

iphone - 我不应该为 UIViewController 属性使用 (nonatomic, weak) 吗?

转载 作者:行者123 更新时间:2023-11-28 22:50:38 26 4
gpt4 key购买 nike

我的其中一个对象有一个属性,如下所示:

@property(nonatomic, weak) UIViewController *myParentViewController;

但是,在 ARC release notes它说:

Note: In addition, in OS X v10.7, you cannot create weak references to instances of NSFontManager, NSFontPanel, NSImage, NSTableCellView, NSViewController, NSWindow, and NSWindowController. In addition, in OS X v10.7 no classes in the AV Foundation framework support weak references.

所以我改为将属性更改为 assign,但是现在当我键入 myParentViewController 时,自动完成显示它是 unsafe_unretained,这让我感到害怕我一点点。

这里到底发生了什么?使用unsafe_unretained需要注意什么?我是否正确解读了文档?

最佳答案

UIViewController 不在该列表中,无论如何它仅指 OS X。您误解了文档。适用于 OS X 的内容不一定直接等同于 iOS。

关于iphone - 我不应该为 UIViewController 属性使用 (nonatomic, weak) 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12078027/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com