无法形成委托的弱属性
我有一个看起来像这样的属性:
@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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据苹果的 过渡到 ARC 发行说明,
(注意:需要非常小心非零弱引用......)
According to Apple's Transitioning to ARC Release Notes,
(Note: one needs to be very careful with nonzeroing weak references...)