无法形成委托的弱属性

发布于 2025-01-03 14:39:46 字数 430 浏览 2 评论 0原文

我有一个看起来像这样的属性:

@property (weak, nonatomic) id<NavigationControllerDelegate> delegate;

但是当我运行我的应用程序时,我收到以下错误:

objc[4251]: cannot form weak reference to instance (0x101e0d4b0) of class TabBarController

我可以从谷歌获得此错误的唯一原因是,当您尝试形成对覆盖的对象的弱引用时,您会得到它保留/释放/释放,我不是。我的 TabBarController 继承自 NSViewController。

有谁知道这可能是什么原因造成的?如果我使用“分配”,它会起作用,但显然我更喜欢使用“弱”。

I have a property that looks like this:

@property (weak, nonatomic) id<NavigationControllerDelegate> delegate;

But when I run my app I get the following error:

objc[4251]: cannot form weak reference to instance (0x101e0d4b0) of class TabBarController

The only reason I can get from google for this error is that you get it when you try to form a weak reference to an object that overrides retain/release/dealloc, which I am not. My TabBarController is inheriting from NSViewController.

Anyone knows what might cause this? It works if I use "assign", but obviously I'd prefer to use "weak".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仙气飘飘 2025-01-10 14:39:46

根据苹果的 过渡到 ARC 发行说明

您当前无法创建对以下类的实例的弱引用:

NSATSTypesetterNSColorSpaceNSFontNSMenuViewNSParagraphStyleNSSimpleHorizo​​ntalTypesetterNSTextView

注意:此外,在 OS X v10.7 中,您无法创建对 NSFontManagerNSFontPanelNSImageNSTableCellViewNSViewControllerNSWindowNSWindowController。此外,在 OS X v10.7 中,AV Foundation 框架中的类不支持弱引用。

(注意:需要非常小心非零弱引用......)

According to Apple's Transitioning to ARC Release Notes,

You cannot currently create weak references to instances of the following classes:

NSATSTypesetter, NSColorSpace, NSFont, NSMenuView, NSParagraphStyle, NSSimpleHorizontalTypesetter, and NSTextView.

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.

(Note: one needs to be very careful with nonzeroing weak references...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文