Why use ivars for IBOutlets instead of properties?

39 Views Asked by At

I just started to work on a new project. It has a lot of legacy code and I found the following code

@interface WLLeftSideViewController : UIViewController {

@private
    __weak IBOutlet UIButton *_signInButton;
    __weak IBOutlet UIButton *_signOutButton;
    __weak IBOutlet UILabel *_nameLabel;
    __weak IBOutlet UILabel *_emailLabel;
    __weak IBOutlet WLLeftSideMenuView *_tableView;
    __weak IBOutlet UIButton *_settingsButton;

    __weak IBOutlet NSLayoutConstraint *_heightConstraint;
}

I have a couple of doubts:

  • What could be the advantage of using private ivars for an IBOutlet?
  • Why add the __weak? As I understand in ARC environment ivars are always weak.

Thanks

1

There are 1 best solutions below

0
Cy-4AH On

The key word here is legacy

  • No advantages
  • All variables (ivars and not) by default is strong.