Re: Performing actions before logging out
Re: Performing actions before logging out
- Subject: Re: Performing actions before logging out
- From: Scot Gellock <email@hidden>
- Date: Wed, 01 Jan 2003 07:38:40 -0800
On 12/31/02 6:43 AM, "Arthur VIGAN" <email@hidden> wrote:
>
Hi,
>
>
I have an application which is a just a front-end to a background
>
process, but I have a little problem when I logout. To quit my
>
application I use a custom method which finishes by [NSApp
>
terminate:nil], and everything works fine. But when I logout, this
>
method is not called, and so the background processed isn't killed.
>
So my question is: how can I call my quitting method when a "logout
>
signal" is received?
>
>
Thanks in advance,
>
>
Arthur
>
_______________________________________________
>
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.
Logout and system shutdown comes to you as an event. You need to add an
observer to the notification center. Here is some quick sample code:
NSNotificationCenter *nc;
nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(workspaceWillPowerOff:)
name:@"NSWorkspaceWillPowerOffNotification"
object:nil];
The code for the event handler is as follows. The code just tosses up a
alert panel for demonstration purposes:
- (void)workspaceWillPowerOff:(NSNotification *)aNotification
{
// you can get the NSWorkspace object
// in the following manner:
//
// NSWorkspace *myWorkspace;
// myWorkspace = (NSWorkspace *)[aNotification object];
//
NSRunAlertPanel(@"MyDocument",
@"inside my document's workspaceWillPowerOff",
nil, nil, nil);
}
Scot
_______________________________________________
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.