Re: currentDocument returns nil (and it shouldn't)
Re: currentDocument returns nil (and it shouldn't)
- Subject: Re: currentDocument returns nil (and it shouldn't)
- From: Patrick Meirmans <email@hidden>
- Date: Tue, 3 Jan 2006 15:37:08 -0500
I had the same problem with [NSApp mainWindow], which also returns nil
when windowDidBecomeMain is called when switching back from another
application. Most likely, currentDocument calls mainWindow so that both
problems are actually the same. I find it quite ironic that mainWindow
returns nil on a windowDidBecomeMain notification.
My work-around was simply to use the notification object:
MyDocument *mainDocument = [[[notification object] windowController]
document];
Best, Patrick
On 31 Dec, 2005, at 14:14, Huibert Aalbers wrote:
Hi,
I am developing a document based application. The class that extends
NSDocument is also a delegate for the document window. I use the
windowDidBecomeMain method to detect when a document is brought to the
front and update the palette windows. The palette window controllers
use [[NSDocumentController sharedDocumentController] currentDocument]
to find out the current document. Everything works fine when I switch
from one document to another. However, when I bring another
application to the front and then switch back to my app, the
windowDidBecomeMain method is invoked but [[NSDocumentController
sharedDocumentController] currentDocument] returns nil. Any ideas as
to what is happening and how I can fix or get around this behaviour?
Regards,
Huibert
--
Viisit my home page at http://www.huibert-aalbers.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden