Search code examples
cocoaappkit

Equivalent of `loadViewIfNeeded` for cocoa?


I'm looking for equivalent function on AppKit for UIKit's loadViewIfNeeded. (this is in order to populate outlets programmatically).

Thank you


Solution

  • You just need to reference the view on the NSViewController. Since you didn't specify the language, I'll give the answer in both Objective-C:

    (void)viewController.view;
    

    and Swift:

    _ = viewController.view