user187676
user187676

Reputation:

Get associated NSDocument for window

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?

Upvotes: 0

Views: 617

Answers (1)

JeremyP
JeremyP

Reputation: 86651

Try getting the window's window controller. It might have a document property which is set

MyDocument* doc = [[theWindow windowController] document];

Upvotes: 2

Related Questions