macOS/iOS API解説

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

目次

NSWorkspaceApplicationKey User Info Key

INDEX>AppKit>NSWorkspace

追加情報のアプリケーションキー

Objective-C

NSString * const NSWorkspaceApplicationKey;

Swift

let NSWorkspaceApplicationKey: String

解説

フレームワーク

ApplicationKit

クラス

NSWorkspace

使用可能

10.6-

更新時のバージョン

OS X 10.10.3
Swift1.2

参照

関連記事(外部サイト)

例文

Objective-C

Swift

    //NSWorkspace NSWorkspaceWillLaunchApplicationNotification
    //NSWorkspace NSWorkspaceApplicationKey
    //アプリケーションが起動しようとするとき
    //
    var switch048 : Bool = false
    func notifyNSWorkspaceWillLaunchApplicationNotification(notify:NSNotification) {
        //NSLog("%@",notify.description)
        
        let bundleID : String = (notify.userInfo! as Dictionary)["NSApplicationBundleIdentifier"]! as! String
        NSLog("Bundle ID = %@",bundleID)
        // -> Bundle ID = com.apple.mail
        
        let appName : String = (notify.userInfo! as Dictionary)["NSApplicationName"]! as! String
        NSLog("application name = %@",appName)
        // -> application name = メール
        
        let appPathe : String = (notify.userInfo! as Dictionary)["NSApplicationPath"]! as! String
        NSLog("application path = %@",appPathe)
        // -> application path = /Applications/Mail.app
        
        let appProcessID : NSNumber = (notify.userInfo! as Dictionary)["NSApplicationProcessIdentifier"]! as! NSNumber
        NSLog("process id = %d",appProcessID.integerValue)
        // -> process id = 36580
        
        let appProcessSerialNumberHigh : NSNumber = (notify.userInfo! as Dictionary)["NSApplicationProcessSerialNumberHigh"]! as! NSNumber
        NSLog("process serial number high = %d",appProcessSerialNumberHigh.integerValue)
        // ->process serial number high = 0

        let appProcessSerialNumberLow : NSNumber = (notify.userInfo! as Dictionary)["NSApplicationProcessSerialNumberLow"]! as! NSNumber
        NSLog("process serial number low = %d",appProcessSerialNumberLow.integerValue)
        // ->process serial number low = 5145832
        

        let runningApp : NSRunningApplication = (notify.userInfo! as Dictionary)["NSWorkspaceApplicationKey"]! as! NSRunningApplication
        NSLog("runningApp = %@",runningApp.description)
        // ->runningApp = <NSRunningApplication: 0x600000105340 (com.apple.mail - 36867)>
        NSLog("runningApp = %@",runningApp.launchDate!.description)
        // ->runningApp = 2015-04-29 09:18:27 +0000
        
    }