macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

active

INDEX>AppKit>NSApplication

アプリケーションがアクティブかどうか

Objective-C

@property(getter=isActive, readonly) BOOL active

Swift

var active: Bool { get }

解説

アプリケーションがアクティブかどうかを返します。

設定値

Objective-C

BOOL active

Swift

Bool { get }

フレームワーク

ApplicationKit

クラス

NSApplication

使用可能

10.10

更新時のバージョン

OS X 10.10

参照

関連記事(外部サイト)


NSApplication Class Reference

例文

    //NSApplication active
    @IBAction func function047(sender: AnyObject) {
        //共有アプリケーションインスタンスを取得
        let anApplication = MyApplication.sharedApplication()
        //
        if (anApplication.active) {
            NSLog("NSApplication active")
            anApplication.hide(self)
            //タイマー作成
            var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("hideCheck:"), userInfo: nil, repeats: false)
        }else{
            NSLog("NSApplication not active")
        }
    }
    //タイマーが起動した時の実行メソッド
    func hideCheck(timer:NSTimer!) {
        let anApplication = MyApplication.sharedApplication()
        //
        if (anApplication.active) {
            NSLog("NSApplication active")
        }else{
            NSLog("NSApplication not active")
        }
    }