Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 978
devios1 Avatar asked Nov 24 '22 03:11

devios1


1 Answers

Here is what I do:
Try to give unique names to your outlets, and then use the "open quickly" window (cmd + shift + o) to find your outlet.

Unfortunately xcode doesn't have jump to outlet like in Visual Studio or any other reasonable IDE does. Apple being Apple, forces you to name your outlets seperately rather than using an ID reference, but does not implement jumping, and requires interface builder to bind outlets in the first place. This is all nonsense, so best you can do is to use a predicatable pattern when naming outlets.

like image 196
MuhsinFatih Avatar answered Mar 19 '23 11:03

MuhsinFatih