3hg453
3hg453

Reputation: 13

Xcode 6 interface builder, cannot link storyboard window to code

I am a relatively new developer working with swift in Xcode 6.1 beta. I am trying to make a simple application that has 2 text fields: 1 for first name, 1 for last name. When the submit button is pressed, a new window opens and displays the full name.

I have successfully gotten the application to work on a single window, with the result appearing in a third non-editable text field.

However, when I add the second view controller to the storyboard for the new window, make it launch when the button is pushed, and drag the result field into it, the application does not work.

I tried re-linking the field to my ViewController.swift (where all my code is), but it does not show up on automatic. When I open it via manual, I cannot link to the file.

original window: https://i.sstatic.net/C0xui.png

new window: https://i.sstatic.net/XdZ2l.png

Viewcontroller.swift:

import Cocoa

class ViewController: NSViewController {

@IBOutlet var window: NSView!
@IBOutlet weak var first: NSTextField!
@IBOutlet weak var last: NSTextField!
@IBOutlet weak var output: NSTextField!


override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}


@IBAction func btn(sender: AnyObject) {


    var first = self.first.stringValue
    var last = self.last.stringValue

    if first.isEmpty {
        self.output.stringValue = ""
    }
    else {
        self.output.stringValue = "Hello, \(self.first.stringValue) \(self.last.stringValue)!"
    }

}



override var representedObject: AnyObject? {
    didSet {


        }





    }


}

Upvotes: 1

Views: 608

Answers (1)

Christian
Christian

Reputation: 329

You have to show assistant window in the menu View > Assistant Editor > Show Assistant Editor

Upvotes: 1

Related Questions