typeOfFile:error:
指定されたファイルのUTIタイプを返します
- (NSString *)typeOfFile:(NSString *)absoluteFilePath error:(NSError **)outError
func typeOfFile(_ absoluteFilePath: String, error outError: NSErrorPointer) -> String?
返り値
フレームワーク
ApplicationKit
クラス
NSWorkspace
使用可能
10.5-
更新時のバージョン
OS X 10.10
参照
関連記事(外部サイト)
例文
//NSWorkspace typeOfFile @IBAction func function017(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 } }//if result }//openPanel.beginWithCompletionHandler }