Create a view controller from Nib with Swift

I am trying to follow this guide: http://www.raywenderlich.com/17811/how-to-make-a-simple-mac-app-on-os-x-10-7-tutorial-part-13

But do it in Swift.

Trying to take the step of creating a view wizard, I have this code:

    import Cocoa

class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet var window: NSWindow
    @IBOutlet var vc: MasterViewController?

    func applicationDidFinishLaunching(aNotification: NSNotification?) {
        vc = MasterViewController(nibName: "MasterViewController", bundle: nil)
    }

    func applicationWillTerminate(aNotification: NSNotification?) {
        // Insert code here to tear down your application
    }


}

However, when I create an instance of MasterViewController, I get the error: Could not find overload for '__conversion', which takes the provided arguments

What am I doing wrong?

+4
source share
2 answers

I think this is an error, because the documentation says that the package may be null, but in fast it does not allow, it throws this error.

NSBundle.mainBundle() , .

NSViewController:

nib. nil, nib .

0

xcode Swift.

nil, NSViewController init:

init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?)

, NSViewController, xcode init :

init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle)

? NSBundle. , nil NSBundle.

, . NSBundle NSBundle? init, .

0

Source: https://habr.com/ru/post/1544457/


All Articles