Swift For Dummies
Book image
Explore Book Buy On Amazon

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:

  1. Open Main.storyboard.

    Your main storyboard may have a different name; this is the default name.

  2. 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.

  3. 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.

  4. Control-drag the cursor from the button on the canvas to the declarations at the top of the view controller file.

  5. 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.

  6. Click Connect.

About This Article

This article is from the book:

About the book author:

Jesse Feiler is a developer, consultant, and author specializing in Apple technologies. He is the creator of Minutes Machine for iPad, the meeting management app, and Saranac River Trail and is heard regularly on WAMC Public Radio for the Northeast’s The Roundtable.

This article can be found in the category: