Pregunta

He escaneado la documentación y el googled bastante extensamente y no encontré nada sobre este tema.

Lo que necesito hacer es interactuar con una instancia específica de uno de mis NSWINDOWS: es decir, uno creado a través del sistema NSDocument PUT INTEGUT creando una aplicación basada en documentos en Xcode.

¿Entonces hay una manera de hacer esto?Algo como [[nsshareddocumentcontroller frontmentwindow] Subview: DOACTION], Tal vez?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top