1
내 Mac OS 응용 프로그램이 종료되면 사용자에게 "[Yes] [No]"를 종료 하시겠습니까? "라고 묻고 싶습니다. 도크 내 응용 프로그램을 마우스 오른쪽 버튼으로 클릭 한 후 "종료"를 선택하면 그 제공NSAppleEventManager를 사용하여 ALL quit 이벤트를 catch하십시오.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
// Install a custom quit event handler
NSAppleEventManager* appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self andSelector:@selector(handleQuitEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
}
// Handler for the quit apple event
- (void)handleQuitEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent {
// Insert YES/NO-dialog here
// if(blahahaha..
//[NSApp terminate:self];
}
을하지만 그것은 단지 종료 잡기 :
나는이 시도했다. Cmd-Q를 누르거나 앱 메뉴에서 종료를 선택하면 내 처리기가 호출되지 않습니다 ...
감사합니다. – user872661