title: What's the best way to pass an object to an NSViewController on application launch?
body: <p>In my <code>AppDelegate</code>'s <code>applicationDidFinishLaunching</code> I need to create an object using data read from disk, and then pass this object to the initial view controller for display. What would be the best way to do this?</p>
  
  <p>Right now I'm loading the storyboard programatically like so:</p>
  
  <pre><code>func applicationDidFinishLaunching(_ aNotification: Notification) {
      importantThing = ImportantThing()
      importantThing.load(url: URL(fileURLWithPath: "..."))
  
      let storyboard = NSStoryboard(name: "Main", bundle: nil)
      myWindowController = storyboard.instantiateController(withIdentifier: "MyWindowController") as! NSWindowController
      (myWindowController.contentViewController as? MyViewController)?.importantThing = importantThing
      myWindowController.showWindow(self)
  }
  </code></pre>
  
  <p>But this feels clunky. For one, the property is being set after <code>viewDidLoad</code>, so now view setup is weird.</p>
  
  <p>There must be a better way to do this. If possible, I would like to not resort to using a singleton, because I actually need to set up a few interconnected objects (two objects with important state that have references to each other, but it doesn't make sense for either to contain the other). What would be a good way to solve this?</p>