How do you use Interface builder with Swift?

Jason Moore picture Jason Moore · Jun 3, 2014 · Viewed 30.8k times · Source

When hooking Swift code up to a Storyboard, how do you add the IBAction and IBOutlet tags?

Answer

Jason Moore picture Jason Moore · Jun 3, 2014

Add IBAction and IBOutlet attributes to variables and functions so they can be visible in Interface builder.

class ViewController: UIViewController {

    @IBOutlet var label: UILabel?

    @IBAction func doTap(x:UIButton) {
        println("Tapped: \(x)")
    }
}