, NSDistributedNotificationCenter . , NSDistributedNotificationCenter root.
, , GUI- , - . NSWorkspace (NSWorkspaceSessionDidBecomeActiveNotification, NSWorkspaceSessionDidResignActiveNotification), , .., .
, GUI , 3 . , , , NSDistributedNotificationCenter, . - .
.h, :
extern NSString * const MDShouldTerminateImmediatelyNotification;
in (an), , ..:
NSString * const MDShouldTerminateImmediatelyNotification = @"MDShouldTerminateImmediately";
- (id)init {
if (self = [super init]) {
[[NSDistributedNotificationCenter defaultCenter]
addObserver:self
selector:@selector(shouldTerminateImmediately:)
name:MDShouldTerminateImmediatelyNotification
object:nil];
}
return self;
}
- (void)dealloc {
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)shouldTerminateImmediately:(NSNotification *)notification {
if (ourInstanceIsInControl == NO) {
[NSApp terminate:nil];
}
}
, , - , :
- (void)beginUpdate {
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:MDShouldTerminateImmediatelyNotification
object:[self description]
userInfo:nil
options:NSNotificationDeliverImmediately | NSNotificationPostToAllSessions];
}
, , ...
, , root, , Launchd ( , , ).
:
TN2083
root Login
d