Frage

Ich habe die Dokumentation gescannt und fair intensiv gegossen und nichts zu diesem Thema gefunden.

Was ich tun muss, ist mit einer bestimmten Instanz eines meiner Nswindows Interact zu interagieren - das heißt, eines über das NSDocument-System erstellt, indem er eine dokumentbasierte Anwendung in Xcode erstellt.

Gibt es also einen Weg, um dies zu tun?So etwas wie [[nsshareddocumentcontroller frontstewindow] subview: doection], vielleicht?

War es hilfreich?

Lösung

To obtain the frontmost window (aka the main window), use -[NSApplication mainWindow]:

NSWindow *mainWindow = [NSApp mainWindow];

To obtain the window corresponding to a given document:

NSDocument *someDocument; // reference to the document you’re interested in
NSWindow *window = [[[someDocument windowControllers] objectAtIndex:0] window];

NSDocument creates a single window controller to manage the corresponding document window, so -[NSDocument windowControllers] returns an array with a single element corresponding to the window controller. -[NSWindowController window] returns the window managed by that window controller.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top