xcodeinterface-builder

Xcode: Go to definition of outlet


So I'm coming from a background in C# WinForms/WPF and am trying to get my head wrapped around how Xcode ties visual UI elements in Interface Builder to their entities in code.

In WPF I'm used to just defining the id of an element and then accessing that as a member in code. In JavaScript it's similar except I have to call document.getElementById first.

However, Xcode and its outlets are really throwing me for a loop. Let's say I have an interface and create a view in a window. Now I want to be able to access that view programmatically, but first I have to define an outlet for that view and graphically "tie" the view to the outlet? Complaints of unnecessary work aside, my next question is is there a quick and easy way to get to that outlet definition from the Interface Builder?

In code I can command-click an identifier to go to its definition, but that doesn't seem to work in this window:

enter image description here

I just want to go to the definition of menu so I can work with it. Is there a shortcut to do that, or do I have to find the controller file and search for "menu" myself?


Solution

  • Use the assistant editor! It can automatically follow along as you select objects in Interface Builder, showing their header files.

    Then, to create your outlet, instead of writing the definition and control-dragging within Interface Builder, you can just control-drag from the Interface Builder view to a blank spot in the header file in the other half of the assistant editor.