@dfri의 의견 덕분에,이 작업을 수행 할 수있는 방법을 찾아 냈습니다 (링크 된 대답에 표시된 것과 정확히 일치하지는 않지만). 파인더의 NSRunningApplication
개체를 관찰하는 것은 (객체 때문에 내가 관찰자를 제거하기 전에 종료에 ialized deinit
이었다) 가능하지 않았다 때문에
, 나는 NSWorkspace.sharedWorkspace().notificationCenter
NSWorkspace.sharedWorkspace().notificationCenter.addObserver(self, selector: #selector(MyController.applicationWasTerminated(_:)), name: NSWorkspaceDidTerminateApplicationNotification, object: nil)
에서 NSWorkspaceDidTerminateApplicationNotification
을 관찰 결국 나는 다음 제거 할 수 있습니다
func applicationWasTerminated(notification: NSNotification?) {
guard let notif = notification else { return }
guard let userInfo = notif.userInfo as? [String : AnyObject] else { return }
guard let identifier = userInfo["NSApplicationBundleIdentifier"] as? String else { return }
if identifier == "com.apple.finder" {
NSWorkspace.sharedWorkspace().launchAppWithBundleIdentifier("com.apple.finder", options: NSWorkspaceLaunchOptions.Default, additionalEventParamDescriptor: nil, launchIdentifier: nil)
}
}
는 당신에게 당신이 강제로 죽일보다는에도 그만 보내시겠습니까 : 내 컨트롤러가
deinit
이 ialized하고, 선택되어이 관찰자는 다음과 같습니다 그 다음에 하나를 활성화 시키시겠습니까? – dfri나는 그것이 실제로 가능하다는 것을 몰랐다. 이 용도로 AppleScript를 사용해야합니까? 답변으로 예제를 게시 할 수 있습니까? 그게 나를 도울거야 – beeb
(obj-C, 코코아) 당신을 도울 수있는 [이 답변] (http://stackoverflow.com/a/10226948/4573247) 참조하십시오. 또는 AppleScript를 사용하여 [this answer] (http://stackoverflow.com/a/1462686/4573247)에서 도움을받을 수 있는지 확인하십시오 (obj-C, AppleScript). – dfri