frontmostApplication
最前面のアプリケーション
@property(readonly, strong) NSRunningApplication *frontmostApplicationvar frontmostApplication: NSRunningApplication? { get }
解説
最前面のアプリケーション
設定値
@property(readonly, strong) NSRunningApplication *frontmostApplicationvar frontmostApplication: NSRunningApplication? { get }
フレームワーク
ApplicationKit
クラス
NSWorkspace
使用可能
10.0
更新時のバージョン
OS X 10.10
参照
関連記事(外部サイト)
例文
//タイマーが起動した時の実行メソッド func timer027(timer:NSTimer!) { //選択したファイルを let theWorkspace : NSWorkspace = NSWorkspace.sharedWorkspace() NSLog("%@",(theWorkspace.frontmostApplication?.description)!) // -> <NSRunningApplication: 0x600000101290 (com.apple.dt.Xcode - 1148)> // -> <NSRunningApplication: 0x600000101290 (com.apple.dt.Xcode - 1148)> // -> <NSRunningApplication: 0x600000101290 (com.apple.Safari - 1549)> } @IBAction func function027(sender: AnyObject) { let anApplication = NSApplication.sharedApplication() //アプリケーションを隠す anApplication.hide(self) //タイマー作成 var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("timer027:"), userInfo: nil, repeats: true ) }