Connecting the design file with the code file in Xcode

By Majid Almaadeed, 27 December, 2018

Forum
App Development and Programming

Hi all,
How can I make a connection between the UIElement and the swift source code file.
I tried to drag and drop the UIelement into the Swift source code file but as I expected it doesn't work. I tried to drag the UIElement from the canvas instead of dragging it from the document outline the Voiceover said that it dropped but nothing happened.
And I tried to copy and paste the UIElement but it doesn't work also.
I am using the assistant editor and I am using the latest version of Xcode

Options

Comments

By mehgcap on Sunday, December 23, 2018 - 02:43

First, write your @IBOutlet for the element in the Swift file. Now interact with the ruler next to the source code text area, and note the new outlet button there. The same will happen for a function that begins with @IBAction. Lock the mouse down on the button, use VO to navigate to the outline of your storyboard, find the element to which to bind, and release the mouse. This should change the status of the button from "not connected" to "connected".

By Blade Runner on Saturday, March 23, 2019 - 02:43

Drag from the connections inspector to the class declaration in the assistant editor. Make sure the vo is on a white space when you release the mouse. That won't be an issue when Using Swift.