How do I properly retrieve the NSDocument associated with the document window? I need the NSDocument as data source for displaying data in the window.
Do I have to iterate over all open documents and check if my instance is equal to the document's -windowForSheet
or is there a more suitable option?
Try getting the window's window controller. It might have a document property which is set
MyDocument* doc = [[theWindow windowController] document];