macOS/iOS API解説

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

目次

unmountAndEjectDeviceAtURL

INDEX>AppKit>NSWorkspace

URLで指定したデバイスをアンマウントします

Objective-C

- (BOOL)unmountAndEjectDeviceAtURL:(NSURL *)url
                             error:(NSError **)error

Swift

func unmountAndEjectDeviceAtURL(_ url: NSURL,
                          error error: NSErrorPointer) -> Bool

解説

URLで指定したデバイスをアンマウントします。

返り値

Objective-C

BOOL

Swift

Bool

引数

Objective-C

(NSURL *)url

Swift

_ url: NSURL

Objective-C

(NSError **)error

Swift

error: NSErrorPointer

フレームワーク

ApplicationKit

クラス

NSWorkspace

使用可能

10.6

更新時のバージョン

OS X 10.10.3
Swift1.2

参照

関連記事(外部サイト)

例文

Objective-C

Swift

    //NSWorkspace unmountAndEjectDeviceAtURL
    func buttonAction034(sender: AnyObject){
        
        let theWorkspace : NSWorkspace = NSWorkspace.sharedWorkspace()
        let theURL : NSURL = NSURL(fileURLWithPath: "/Volumes/ディスクイメージ")!
        var theError : NSError? = NSError()
        let result : Bool  = theWorkspace.unmountAndEjectDeviceAtURL(theURL, error: &theError)
        
        if result {
            NSLog("OK")
        }else{
            NSLog("NG %@",(theError?.description as String?)!)
            NSLog("NG %d",(theError?.code as Int?)! )
            NSLog("NG %@",(theError?.domain as String?)! )
        }

    }