Search code examples
cocoaautomatic-ref-countingweak-referencesiboutlet

Weak IBOutlet property and ARC issue


my code:

@interface WBMessageTableCellView : NSTableCellView

@property (weak) IBOutlet NSTextField *authName;
@property (weak) IBOutlet NSTextField *createdTime;
@property (weak) IBOutlet NSImageView *userProfileImageView;

@property (weak) IBOutlet NSTextView *statusTextView;

@end

but I got this error, enter image description here what's wrong with this? I have to change my code to this, and it works,

@interface WBMessageTableCellView : NSTableCellView
{
    IBOutlet NSTextView *statusTextView;
}

@property (weak) IBOutlet NSTextField *authName;
@property (weak) IBOutlet NSTextField *createdTime;
@property (weak) IBOutlet NSImageView *userProfileImageView;

@property NSTextView *statusTextView;

I have arc turned on on this file, and the project is newly created. not converted from non-arc project.


Solution

  • I've promoted my comment to an answer:

    Please take a look at this question: Which iOS classes that don't support zeroing weak references? You can't create weak references to classes which don't support weak references to their instances.