Xcode has Interface Builder built into it so that you can design your interface graphically. The key to making it all work is to connect the graphical elements from Interface Builder to your Swift files. Xcode makes it easy — just follow these steps:
Open Main.storyboard.
Your main storyboard may have a different name; this is the default name.
Arrange the interface as you want it for the given scene.
For example, drag a bar button item onto a view. Select Action for its identifier in the Attributes inspector.
Switch to the Assistant so that you see the code for your view controller on one side and the Interface Builder design canvas on the other.
Control-drag the cursor from the button on the canvas to the declarations at the top of the view controller file.
Select Action from the pop-up menu and name the action. (For a property, choose Outlet from the pop-up menu and name the outlet in the same way.)
Xcode builds the shell of the action function for you to implement.
Click Connect.