NSWorkspaceActiveSpaceDidChangeNotification
アクティブスペースが変更になった場合の通知
解説
フレームワーク
ApplicationKit
クラス
NSWorkspace
使用可能
10.0
更新時のバージョン
OS X 10.10.3
Swift1.2
参照
関連記事(外部サイト)
例文
//NSWorkspace NSWorkspaceDidPerformFileOperationNotification //NSWorkspace NSWorkspaceDidChangeFileLabelsNotification //NSWorkspace NSWorkspaceActiveSpaceDidChangeNotification var switch054 : Bool = false func notify054(notify:NSNotification) { NSLog("!! %@",notify.description) if notify.name == NSWorkspaceDidPerformFileOperationNotification { //通知飛んでこない } if notify.name == NSWorkspaceDidChangeFileLabelsNotification { //通知飛んでこない } //アクティブスペースが切り替わった if notify.name == NSWorkspaceActiveSpaceDidChangeNotification { NSLog("NSWorkspaceActiveSpaceDidChangeNotification") } } @IBAction func function054(sender: AnyObject) { let notificationName1 : String = NSWorkspaceDidPerformFileOperationNotification let notificationName2 : String = NSWorkspaceDidChangeFileLabelsNotification let notificationName3 : String = NSWorkspaceActiveSpaceDidChangeNotification let notificationSelector : Selector = Selector("notify054:") if switch054 { //通知の監視をやめる NSWorkspace.sharedWorkspace().notificationCenter.removeObserver(self, name: notificationName1, object: nil ) NSWorkspace.sharedWorkspace().notificationCenter.removeObserver(self, name: notificationName2, object: nil ) NSWorkspace.sharedWorkspace().notificationCenter.removeObserver(self, name: notificationName3, object: nil ) NSLog("--------observe off") switch054 = false }else{ //通知の監視を始める NSWorkspace.sharedWorkspace().notificationCenter.addObserver(self, forKeyPath: notificationName1, options:NSKeyValueObservingOptions.New, context: nil) NSWorkspace.sharedWorkspace().notificationCenter.addObserver(self, selector: notificationSelector, name: notificationName1, object: nil ) NSWorkspace.sharedWorkspace().notificationCenter.addObserver(self, selector: notificationSelector, name: notificationName2, object: nil ) NSWorkspace.sharedWorkspace().notificationCenter.addObserver(self, selector: notificationSelector, name: notificationName3, object: nil ) NSLog("--------observe on") switch054 = true } }