Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

weak property for delegate cannot be formed

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".

like image 285
Kenny Lövrin Avatar asked Feb 08 '12 12:02

Kenny Lövrin


1 Answers

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...)

like image 90
Gareth McCaughan Avatar answered Oct 11 '22 18:10

Gareth McCaughan