views:

922

answers:

4

UIViewController has an ivar (and @property) called view. It is not however, an IBOutlet.

When creating a view nib in Interface Builder, you typically set File's Owner to be your UIViewController (or subclass thereof), and you wire the nib's view to File's Owner's view outlet.

How does this work if the UIViewController view member isn't an IBOutlet?

A: 

The simple answer is that Apple wrote both Interface Builder and UIViewController.

Graham Lee
A: 

The view property of UIViewController is just that, a Property. The whole purpose of a UIViewController is to control a view. The view property allows you to assign that view to an UIViewController. That's the purpose of the view and that's why it shows up in IB. It's a property. Just like textLabel is a property of UILabel.

Jordan
blackColor is a class method on UIColor, not a property! The question was not about the purpose of the view property, but rather why IB treats it as an outlet although there is no IBOutlet declaration on this property.
Daniel Rinser
Added another example of property.
Jordan
textLabel still isn't a property of UILabel. And it's not what this question was about. I do understand properties, just not how UIViewController's view was treated different in IB. But I think I've found my answer now.
jbrennan
+1  A: 

I read this article a while ago and it finally tied it all together for me. Maybe it'll help you?

Meltemi
+3  A: 

The IBOutlet keyword is used to indicate that a property should show up in Interface Builder for classes that you write. Interface Builder internally has additional knowledge about system provided classes.

If you are working with Interface Builder on the desktop, rather than iPhone, you can write Interface Builder Plug-Ins to integrate your custom classes into the Interface Builder Library (This is not supported in Interface Builder for the iPhone). In writing a plug-in, the plug-in author provides "class description" files that declare this same actions/outlets information to Interface Builder as one achieves with the IBAction/IBOutlet keywords. You can read more about it in the Interface Builder Plug-In Programming Guide.

It works essentially the same way for system provided classes as it does for plug-ins.

Joey Hagedorn