Re: NSDocument recent items menu - doc fails to load [solved]
Re: NSDocument recent items menu - doc fails to load [solved]
- Subject: Re: NSDocument recent items menu - doc fails to load [solved]
- From: Christopher Corbell <email@hidden>
- Date: Mon, 7 Apr 2003 11:37:12 -0700
For the archives & posterity, I found that the place to intercept this
is in an application delegate, by implementing the delegate method
- (BOOL)application:(NSApplication *)sender openFile:(NSString
*)filename
The default NSApp implementation calls NSDocumentController's
openDocumentWithContentsOfFile, but to force a document to load one
can instead send the controller makeDocumentWithContentsOfFile followed
by an addDocument message (+ whatever the document needs -
such as makeWindowControllers, showWindows).
Though this solves my problem, I do believe that there is an
NSDocumentController bug here. It apparently has a private
cache of NSDocument objects that it retains completely
independent of its public list of documents, for association with
files in the Open Recent menu. Either removeDocument
should remove documents from this cache as well, or a separate API
should be provided to inspect and remove individual document objects
there (which is not the same as removing the file reference from the
Open Recent menu).
On Sunday, April 6, 2003, at 03:03 PM, Christopher Corbell wrote:
I'm trying to track down the cause for the following behavior
with NSDocument...
[....]
- (THE BUG) - Choose this document again from the recent
documents window, and it does not get opened, -but- the document's
name and icon do appear in the window's title bar. The
initWithContentsOfFile (or URL) method never gets invoked,
nor does any other method telling my app that a document
is being opened. (A side effect is that the current document
does not therefore get closed, so the actual data in the window
represents the former document, not the one just chosen).
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.