Search code examples
macoscocoaappkitnsviewcontroller

What does it mean to "invoke NSViewController" (before creating it)?


In the NSViewController documentation, it says:

If you pass in a nil for nibNameOrNil then nibName will return nil and loadView() will throw an exception; in this case you must invoke NSViewController before Creating A View Controller is invoked, or override loadView().

"Creating A View Controller" links to NSViewController's init() method.

What does it mean to invoke a class, before initializing it? I've been using AppKit for over 10 years and I can't make heads or tails of this sentence.


Solution

  • In the documentation of Xcode 6 the text is:

    If you pass in a nil for nibNameOrNil then nibName will return nil and loadView will throw an exception; in this case you must invoke setView: before view is invoked, or override loadView.

    "setView:" links to the NSViewController class. "view" links to the initWithNibName:bundle: method of NSViewController. Apparently Apple adjusted the text to the links instead of the other way around.