isFilePackageAtPath:
パッケージかを返します
- (BOOL)isFilePackageAtPath:(NSString *)fullPathfunc isFilePackageAtPath(_ fullPath: String) -> Bool
解説
パッケージかを返します。
フレームワーク
ApplicationKit
クラス
NSWorkspace
使用可能
10.0
参照
更新時のバージョン
OS X 10.10.3
Swift1.2
例文
#import "SetImage.h" @implementation SetImage - (IBAction)set:(id)sender { //開けるファイル拡張子の配列 NSArray *fileTypes = [ NSArray arrayWithObject : @"app" ]; //OpenPanelを作る NSOpenPanel *opPanel = [ NSOpenPanel openPanel ]; //OpenPanelの結果のボタン番号 int opRet; //OpenPanelでファイル選択 opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Pictures" //どのどのファイルを選択しておくか types : fileTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:[ opPanel filename ] ]){ NSLog(@"YES"); } else { NSLog(@"NO"); } } } @end
//NSWorkspace isFilePackageAtPath @IBAction func function026(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! // -> hfs,hfs if (theWorkspace.isFilePackageAtPath(filepath as String)) { NSLog("filePackage?:YES") }else{ NSLog("filePackage?:NO") } }//if result }//openPanel.beginWithCompletionHandler }