What is the difference between IBOutlet as a property or as a variable?

前端 未结 2 1784
北恋
北恋 2020-12-21 08:20

There are two different methods to declare IBOutlet.

  1. In @interface section as variable:

    IBOutlet UIButton *exampleButton;
    
2条回答
  •  旧时难觅i
    2020-12-21 08:50

    Either one works fine in my experience. What doesn't work is declaring both the instance variable and the property "IBOutlet" -- that seems to really confuse things. If for some reason you want to avoid providing public access to your outlet, you can declare it as an instance variable and simply not create the property. On the other hand, now that the runtime will synthesize instance variables for you, many people are declaring only properties and skipping the explicit instance variable declaration; in that case, you'd obviously declare the property as the IBOutlet.

提交回复
热议问题