Failed to connect (storyboard) outlet from (NSApplication) to (NSNibExternalObjectPlaceholder) error in Cocoa and storyboard

后端 未结 4 2067
南方客
南方客 2021-02-07 18:14

I\'ve tried to build a sample Cocoa app on which I want to connect UI components put on storyboard to ViewController.swift as either an IBOutlet or

4条回答
  •  独厮守ぢ
    2021-02-07 19:05

    Failed to connect (storyboard) outlet from (NSApplication) to (NSNibExternalObjectPlaceholder): missing setter or instance variable
    

    The IBAction methods working like it should, see Apple Dev Forums:

    "This is a known issue ... The messages are harmless and do not indicate a problem with your code."

    Apple Dev Forums: OS X Storyboard failure

    Thats not why your code is not working, you need to fix the following:

    A) Here is my working code to set the title - using self.view.window.title instead self.title:

    @IBAction func btnSetWindowTitle(sender : AnyObject) {
        if self.txtTitle.stringValue != "" {
            println(self.view.window.title)
            println(self.txtTitle.stringValue)
            self.view.window.title = self.txtTitle.stringValue
        }
    }
    

    B) In Interface Builder you need to set NSBox "Box Type" to "Custom": enter image description here

    And that's it: enter image description here

提交回复
热议问题