Re: my Graceful Application Termination doesn't work with my applicationShouldTerminate
Re: my Graceful Application Termination doesn't work with my applicationShouldTerminate
- Subject: Re: my Graceful Application Termination doesn't work with my applicationShouldTerminate
- From: Francis Derive <email@hidden>
- Date: Thu, 29 Jun 2006 22:42:40 +0200
I will - Alan, with pleasure.
I want to customize a little bit the process of closing documents -
what has to happen if they have been edited or not - as described in
the chapter "Graceful Application Termination" of ADC "Application
Architecture Overview".
This customization would go for showing an enabled "Default Button"
only when a document has been edited AND is also valid as to its
content : it is not worth even to ask for Saving it if the content is
not correct as to the application.
This is the reason - good or bad, anyway an opportunity to understand
this corner of the Cocoa framework, I mean :
- (NSApplicationTerminateReply) applicationShouldTerminate:
(NSApplication *) sender implemented by the App delegate which - copy
of the TextEdit Developer Example -
. looks for the list of edited documents,
. display an alert panel
choice = NSRunAlertPanel(@"You have %d documents with unsaved
changes. Do you want to review these changes before quitting?" , , , )
. in case of NSAlertDefaultReturn choice calls the
reviewChangesAndQuitEnumeration NSDocument subclass class method
and
+ (void)reviewChangesAndQuitEnumeration:(BOOL)cont
- (void)askToSave:(SEL)callback
- (void)willEndCloseSheet:(NSWindow *)sheet returnCode:(int)
returnCode contextInfo:(void *)contextInfo
- (void)didEndCloseSheet:(NSWindow *)sheet returnCode:(int)
returnCode contextInfo:(void *)contextInfo
implemented in an NSDocument subclass, very exactly as in the
TextEdit and Graceful Application Termination example.
The first thing which of any evidence does not work is that when I
Quit the application while several document windows are displayed on
screen, an Alert Panel exactly similar to the one described above in
applicationShouldTerminate: is displayed with the above text "You
have %d documents with unsaved changes. Do you want to review these
changes before quitting?" - EVEN if I change this label to another
one like "You have %d
documents //////////////////////////////////////////// quitting?"
Do you see my trouble ? What happens for another code being executed
in place of mine ?
What happens after is somehow "normal" - saving or not, cancelling,
but I am surprised that the applicationShouldTerminate NSLog traces
are **AFTER** the Saving NSlog traces !
And this "selector not recognized" at the very end which deserve some
attention ...
MyDocument -- dataOfType:error:
2006-06-29 22:33:28.892 BindAtoNConverter[2484] FIN MyDocument --
dataOfType:error:
2006-06-29 22:33:28.893 BindAtoNConverter[2484] AtoNconverter --
encodeWithCoder:
2006-06-29 22:33:28.893 BindAtoNConverter[2484] AtoNconverter --
asciiToConvert:
2006-06-29 22:33:28.894 BindAtoNConverter[2484] FIN AtoNconverter --
asciiToConvert:
2006-06-29 22:33:28.894 BindAtoNConverter[2484] AtoNconverter --
laCouleur:
2006-06-29 22:33:28.894 BindAtoNConverter[2484] FIN AtoNconverter --
laCouleur:
2006-06-29 22:33:28.894 BindAtoNConverter[2484] FIN AtoNconverter --
encodeWithCoder: asciiToConvert 10.11.12.168 laCouleur
NSCalibratedWhiteColorSpace 0 1
2006-06-29 22:33:28.894 BindAtoNConverter[2484] AtoNconverter --
encodeWithCoder:
2006-06-29 22:33:28.894 BindAtoNConverter[2484] AtoNconverter --
asciiToConvert:
2006-06-29 22:33:28.894 BindAtoNConverter[2484] FIN AtoNconverter --
asciiToConvert:
2006-06-29 22:33:28.895 BindAtoNConverter[2484] AtoNconverter --
laCouleur:
2006-06-29 22:33:28.896 BindAtoNConverter[2484] FIN AtoNconverter --
laCouleur:
2006-06-29 22:33:28.896 BindAtoNConverter[2484] FIN AtoNconverter --
encodeWithCoder: asciiToConvert 10.11.12.168 laCouleur
NSCalibratedWhiteColorSpace 0 1
2006-06-29 22:33:34.143 BindAtoNConverter[2484] APdeleg --
applicationShouldTerminate
2006-06-29 22:33:34.144 BindAtoNConverter[2484] *** -[NSAlert
isDocumentEdited]: selector not recognized [self = 0x390870]
2006-06-29 22:33:34.173 BindAtoNConverter[2484] *** -[NSAlert
isDocumentEdited]: selector not recognized [self = 0x390870]
I hope it helps understanding me, and many thanks for your
participation.
Francis.
On Jun 29, 2006, at 9:10 PM, Alan Smith wrote:
Hi Francis,
Would you mind restating your question? I can't tell what you want to
know. Once you've done that I'll do my best to help you with this.
I'll be at your service.
Peace, Alan
_______________________________________________
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