macOS/iOS API解説

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

目次

fullPathForApplication:

INDEX>AppKit>NSWorkspace

アプリケーションのフルパスを返します

Objective-C

- (NSString *)fullPathForApplication:(NSString *)appName

Swift

func fullPathForApplication(_ appName: String) -> String?

解説

アプリケーション名(appName)のアプリケーションのフルパスを返します。
なければnilを返します。

返り値

フルパス
Objective-C

NSString *

Swift

String?

引数

アプリケーション名
Objective-C

(NSString *)appName

Swift

_ appName: String

フレームワーク

ApplicationKit

クラス

NSWorkspace

使用可能

10.0

参照

更新時のバージョン

OS X 10.10.3
Swift1.2


例文

#import "SetImage.h"

@implementation SetImage

- (IBAction)set:(id)sender
{
NSLog([[NSWorkspace sharedWorkspace] fullPathForApplication:@"QuickTime Player"]);
}

@end


Swift

    //NSWorkspace fullPathForApplication
    @IBAction func function024(sender: AnyObject) {
        let theWorkspace : NSWorkspace = NSWorkspace.sharedWorkspace()
        let fullPath : NSString? = theWorkspace.fullPathForApplication("Safari")
        if (fullPath != nil) {
        NSLog("%@", fullPath!)
        }
        ///Applications/Safari.app
    }