macOS/iOS API解説

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

目次

absolutePathForAppBundleWithIdentifier:

INDEX>AppKit>NSWorkspace

アプリケーションバンドルの絶対パスを返します

Objective-C

- (NSString *)absolutePathForAppBundleWithIdentifier:(NSString *)bundleIdentifier

Swift

func absolutePathForAppBundleWithIdentifier(_ bundleIdentifier: String) -> String?

解説

アプリケーションバンドルの絶対パスを返します。

返り値

メニュー
Objective-C

NSString *

Swift

String?

引数

info.plistのCFBundleIdentifierで定義された値
Objective-C

(NSString *)bundleIdentifier

Swift

_ bundleIdentifier: String

フレームワーク

ApplicationKit

クラス

NSWorkspace

使用可能

10.3

参照

更新時のバージョン

OS X 10.10.3
Swift1.2


例文

   NSLog([[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.oomori.image"]);

Swift

    //NSWorkspace absolutePathForAppBundleWithIdentifier
    @IBAction func function035(sender: AnyObject) {
        
        let theWorkspace : NSWorkspace = NSWorkspace.sharedWorkspace()
        NSLog("%@",theWorkspace.absolutePathForAppBundleWithIdentifier("com.apple.safari")! )
        // -> /Applications/Safari.app
    }