File's owner as "hole" in XIB file


I’m not really understanding what a “hole” in a XIB file is (or, for that matter, what a “hole” in any file is supposed to be). I get the idea that the File Owner is, more or less, the controlling object/owner of the objects in the view. But I’m not getting the concept of a “hole” where one drops/places things. Could someone please clarify, or provide a better metaphor? Thanks.


I’ll try to explain it the way I undertand it and I’m sure someone more learnered than me will correct if I go wrong.

The xib file contains an archive of objects which haven’t been created yet. They are created at run time. So when they get created / unarchived they need to be told what instance variables they should link to, if they had no files owner they would not have any idea what type of view controller they would be expected to have so they wouldn’t know what instance variables they could connect to.

Also the view controller would not know which bits of it’s xib file are it’s main view (which is why you connect the ‘view’ from the file’s owner when you’re created from a blank xib file. It’s the same as going setView:)

So say I set up a xib file called ‘ScoreBoard’ and want a view controller called ‘ScoreBoardViewContoller’ to update a label called highScoreLabel.

I need to tell the xib file ‘when you get unpacked and made into a real life object you’re going to have a label that I want your view controller to fill with the high score, so I need you to know your view contoller will be ScoreBoardViewController do that you can see the connections.’

I do this by setting it’s class, now I have the ‘highScoreLabel’ available to connect.

The way this started to make sense in my head was when I started thinking of the classes and xib files as blue prints. These are not the finished objects, they only become objects when the program is running and it uses the blue prints in the .h .m and .xib files to make objects in memory. So you can’t connect the xib file to it’s view controller because neither exist when you are designing the application, but you can tell it when it get’s made into an object another object of a view controller type will be created and you send stuff back and forth.

Until that object is created in memory pretend it’s there by using the ‘files owner’ during the design, and when it’s real files owner will be an object that can receive all the stuff you want to send.

I’m probably making this as clear as mud. I’ll have a think and try to come up with a better way to explain it (and maybe one of the other board people will save me from my lack of communication ability in the mean time :wink: