Search code examples
iosxcodeibactioniboutlet

How to connect an IBOutlet and IBAction to a View Controller without using the Assistant editor


I know the second button here shows the Assistant editor:

enter image description here

And I know how to make an Outlet and Action by Control dragging from an object in the Interface Builder to the View Controller code. Ideally it should be as easy as the documentation makes it look:

enter image description here

But this is usually what Xcode actually looks like for me when I press the "Assistant" editor:

enter image description here

A mess. I have to minimize lots of things, try to get the storyboard object in view, and then go find the right View Controller. All this before I can do the Control-drag.

Is there a way to make the connection without using the Assistant editor? (And preferably without having to type a lot of code in myself.)


Solution

  • Don't press the assistant editor button. Sometimes it opens a random file instead of the one you want.

    When you are in Storyboard, Option click on the .h file that you want to open in the Project Navigator. This will open the proper .h file to add the outlets or actions.

    When you're done, close the Assistant editor right pane (which is displaying the .h file) and you will be back in Storyboard.