Access NSDocument from NSViewController and vice versa

Viewed 2267

What is the correct way to access the NSDocument subclass from its associated NSViewController subclass and vice versa?

I have the following code that does the former, but it doesn't work when the view has loaded or when it moved to a window:

var document: Document {
    return NSDocumentController.sharedDocumentController().documentForWindow(view.window!) as! Document
}
1 Answers
Related