32

I have myController.h and myController.m defined, and proceeded to create a myController.xib with the Wizard. I can't, however, connect the controls from the xib file to the class interface. Usually when I drop the connection cross hair on the File's Owner icon, it'll show me a list of properties that have been declared as IBOutlet, but this time it's just nothing.

I thought the names of the class files and XIB file (myController) automatically binds File's Owner, but apparently that is not the case.

How can I manually bind the two?

Haoest
  • 13,610
  • 29
  • 89
  • 105

6 Answers6

57

Go to the Identity Inspector (Cmd+Option+3) and change the class to myController.

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
12

Here it is in 5.1:

enter image description here

I thought I would add this screenshot as it took me some time to find it!

Patrice Gagnon
  • 1,276
  • 14
  • 14
4

Had the same question... XCode 4.2 enables to create a subclass of UIViewController and there you can optionally check the "with XIB for user interface" option.

New File... >> UIViewControler subclass >> "with xib..."

radekEm
  • 4,617
  • 6
  • 32
  • 45
4

I found a way to do it manually... When the world is not using XIB(s) anymore... Open the XIB or NIB file in your favourite text editor

you will find this line there...

        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MyClassName">

Change the MyClassName to the class you want to refer it to, save the file and your file's owner will be changed. Caution: Close Xcode (To auto reload the changes) and also take a backup in case you mess up something.

jeet.chanchawat
  • 5,842
  • 5
  • 38
  • 59
2

I've experienced the same issue while in Xcode 4: while trying to make a connection to file's owner, the icon did not respond while dragging the connection line and hovering over file's owner. Resetting the custom class didn't work. I ended up trying quitting and restarting Xcode and only this did the trick.

Tom
  • 2,674
  • 1
  • 25
  • 33
0

If you are looking an answer for the same problema in Xcode 12.1, just set the class for the view, and restart Xcode, it will do the trick.

Alessandro Pace
  • 206
  • 4
  • 8