0

Is everything declared within the braces following a class declaration in a header file an IBOutlet, even if you don't write IBOutlet? I notice when following some tutorials the IBOutlet word is missing for some instance variables declared within the braces, but then after the closing brace they will be defined again as a property with the word IBOutlet.

neuromancer
  • 47,047
  • 74
  • 161
  • 217

1 Answers1

2

IBOutlet is just a preprocessor macro that expands to "" (the empty string). You annotate fields or properties with it so that Interface Builder knows which variables can be the target of connections in its UI. As such, you can choose to place the annotation on the field or (if you have one) the property - it conveys the same information to IB. IIRC, the Apple recommendation is to place them on properties (if you have them), but I can't find the reference.

The question of whether you need properties for IBOutlet fields or not is more interesting, and some of the ramifications are covered in: Does an IBOutlet needs to be a property & synthesized? and What happens if I don't retain IBOutlet?

Community
  • 1
  • 1
Adam Wright
  • 47,483
  • 11
  • 126
  • 149
  • What happens if you put them in both the field and the property? Is that the same as just putting it in the property? – neuromancer Jul 25 '10 at 23:35