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

后端 未结 4 2063
南方客
南方客 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:12

    I've found another easier solution these days while coding.

    Check this out.

    enter image description here

    1) Select File's Owner in Document Outline in the .xib file.

    enter image description here

    2) Specify the class you want the .xib file to connect with.

    enter image description here

    3) Now when you connect outlet to the source file, just use default File's Owner. Much easier.

    enter image description here enter image description here

    4) I guess it's not enough so far. I've met an exception when running called 'loaded the 'xxx' nib but the view outlet was not set'. We should do something more.

    Select the view in Document Outline. Drag from the circle of New Referencing Outlet to the File's Owner in Document Outline.

    Alright, that's the new easier solution. No additional objects should add into the xib. If it doesn't work, leave comments below.

提交回复
热议问题