Domanda

Ho scansionato la documentazione e google abbastanza ampiamente e non ho trovato nulla su questo argomento.

Che cosa ho bisogno di fare è interagire con un'istanza specifica di uno dei miei NSWINDOWS - cioè uno creato attraverso il sistema NSDocument messo in atto creando un'applicazione basata su documenti in XCode.

Quindi c'è un modo per farlo?Qualcosa come [[NSSHAREDDOCUMENTOCONTROLLER FRONSUMMINTOWINTOW] sottoview: Doazione], forse?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top