Re: Hooking NSDocument close
Re: Hooking NSDocument close
- Subject: Re: Hooking NSDocument close
- From: Jason Harris <email@hidden>
- Date: Fri, 14 Jun 2002 17:41:34 -0700
I've got the following in my NSApp delegate:
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication
*)sender
{
[[NSDocumentController sharedDocumentController]
closeAllDocumentsWithDelegate: self didCloseAllSelector:
@selector(documentController: didCloseAll: contextInfo:) contextInfo: nil];
return NSTerminateLater;
}
- (void)documentController:(NSDocumentController *)docController
didCloseAll:(BOOL)didCloseAll contextInfo:(void *)contextInfo
{
[[NSApplication sharedApplication] replyToApplicationShouldTerminate:
didCloseAll];
}
Hope this helps!
Jason Harris
Donald Brown Tried to Tell Me:
>
WindowWillClose doesn't work if the app is just quitting, and writeToFile
>
won't work because I may not be writing the file. I think NSApp is looking
>
at the dirty state, brining up that dialog "You have three dirty files, want
>
to review, cancel, or quit".
>
>
It's a bit of a puzzler. I really miss not being able to read the class
>
source code like I could with PowerPlant.
>
>
Donald
>
>
on 6/14/02 1:39 PM, Matt Neuburg at email@hidden wrote:
>
>
> On Wed, 12 Jun 2002 16:31:29 -0500, Donald Brown <email@hidden> said:
>
>
>
>> I need to catch when my document is about to go away (so I can save the user
>
>> position). I've overridden canCloseDocumentWithDelegate to save my info and
>
>> then call [super canCloseDocumentWithDelegate...], and this works when the
>
>> document is closed (by clicking in the window's close box or choosing close
>
>> from the menu). But, when the app quits, it's not called. Is there some
>
>> other place I should be patching?
>
>
>
> Have you considered the windowWillClose: notification?
>
>
>
> Alternatively, have you considered overriding writeToFile:ofType:?
>
>
>
> m.
_______________________________________________
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.