Conecting the elements on the Storybord to code

Hello,

Because of my disability it is dificult for me to press the controll key and to drag and drop something at the same time, like you have to do in order to make the conection between the elements in the storyboard and the Viewcontroller.swift file.


So I am wondering whether it is posible to make the conections by typing the corresponding code into the editor instead of playing around with the mouse? Provided you have enough experience to do so. Whitch I don't have yet.:-(


Best Regards


Petra Ritter



Replies

What you can do is use the connections Inspector:


- select the object in Interface Builder

- open the Inspector panel on thr right (with the sqaure at the extreme top right)

- select the last icon on the right, for connections Inspector (circled arrow)

- now you can click on a small circle (like New reference outlet) and drag to the code, with no need to control-drag.

- you can connect to IBAction in the same way


Note: if you right-click on the object in IB, you will see the panel with all the connections. You can use it instead of the Connections Inspector.


Second way is to connect from code.

To illustrate:

- create the object in Interface Builder (a Label)

- declare the var in code

@IBOutlet weak var lengthLabel: UILabel!

=> a small circle appears at its left.

- click and drag (no control drag) from this circle to the object in Interface Builder

- That creates the connection

- You see the small circle turn black.

Did this solve your issue ?


If yes, thanks to close the thread.