localizedDescriptionForType:
UTIタイプの説明
- (NSString *)localizedDescriptionForType:(NSString *)typeName
func localizedDescriptionForType(_ typeName: String) -> String?
解説
返り値
ローカライズされたUTIタイプの説明
Portable Network Graphics image
web internet location
など
Objective-C(NSString *)String?
引数
UTIタイプ
例えば public.png , public.data など
Objective-C(NSString *)typeName(_ typeName: String)
フレームワーク
ApplicationKit
クラス
NSWorkspace
使用可能
10.0
更新時のバージョン
OS X 10.10.3
Swift1.2
参照
関連記事(外部サイト)
例文
//NSWorkspace localizedDescriptionForType @IBAction func function018(sender: AnyObject) { //ファイルを選択 var openPanel = NSOpenPanel() openPanel.allowsMultipleSelection = false openPanel.canChooseDirectories = false openPanel.canCreateDirectories = false openPanel.canChooseFiles = true openPanel.beginWithCompletionHandler { (result) -> Void in //オープンパネルでOKを選択したら if result == NSFileHandlingPanelOKButton { //選択したファイルを let theWorkspace : NSWorkspace = NSWorkspace.sharedWorkspace() let theURL : NSURL = openPanel.URL! let filepath : NSString = theURL.path! var anError : NSError? let utiType : NSString? = theWorkspace.typeOfFile(filepath, error: &anError) if utiType != nil { NSLog("%@", utiType!) //Ex.-> public.png , public.data NSLog("%@", theWorkspace.localizedDescriptionForType(utiType!)!) //Ex.->Portable Network Graphics image , data } }//if result }//openPanel.beginWithCompletionHandler }