unmountAndEjectDeviceAtPath:
パスでアンマウントして、デバイスを排出します
- (BOOL)unmountAndEjectDeviceAtPath:(NSString *)pathfunc unmountAndEjectDeviceAtPath(_ path: String) -> Bool
解説
パスでアンマウントして、デバイスを排出します。
このメソッドが開始するとき、それはNSWorkspaceの通知センターにNSWorkspaceWillUnmountNotificationを掲示する。
それが終わるとき、それはNSWorkspaceDidUnmountNotificationを掲示する。
返り値
アンマウントされたかYES/NO
Objective-CBOOL
Bool
引数
アンマウントするデバイスのパス
(NSString *)path_ path: String
フレームワーク
ApplicationKit
クラス
NSWorkspace
使用可能
10.0
参照
更新時のバージョン
OS X 10.10.3
Swift1.2
例文
//ディスクをマウント解除するので不必要なディスクイメージなどでテストしてください #import "SetImage.h" @implementation SetImage - (IBAction)set:(id)sender { //開けるファイル拡張子の配列 NSArray *fileTypes = [ NSArray arrayWithObject : @"tiff" ]; //OpenPanelを作る NSOpenPanel *opPanel = [ NSOpenPanel openPanel ]; //OpenPanelの結果のボタン番号 int opRet; BOOL openResult; [opPanel setCanChooseDirectories:YES]; //OpenPanelでファイル選択 opRet = [ opPanel runModalForDirectory : @"/" //どこのディレクトリを出すか file : @"Pictures" //どのどのファイルを選択しておくか types : fileTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら openResult = [[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath:[ opPanel filename ] ]; } } @end
//NSWorkspace unmountAndEjectDeviceAtPath func buttonAction033(sender: AnyObject){ let theWorkspace : NSWorkspace = NSWorkspace.sharedWorkspace() let result : Bool = theWorkspace.unmountAndEjectDeviceAtPath("/Volumes/ディスクイメージ") if result { NSLog("OK") }else{ NSLog("NG") } }