簡體   English   中英

為什么將ivars用於IBOutlets而不是屬性?

[英]Why use ivars for IBOutlets instead of properties?

我剛開始從事一個新項目。 它有很多舊代碼,我發現了以下代碼

@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;
}

我有幾個疑問:

  • 對IBOutlet使用私有ivars有什么好處?
  • 為什么要添加__weak? 據我了解,在ARC環境中,ivars總是很薄弱。

謝謝

這里的關鍵詞是遺產

  • 沒有優勢
  • 默認情況下,所有變量(不包括ivars)均為強。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM