<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWorkspace/unmountAndEjectDevice(atPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWorkspace(im)unmountAndEjectDeviceAtPath:"
  },
  "title" : "unmountAndEjectDevice(atPath:)"
}
-->

# unmountAndEjectDevice(atPath:)

Unmounts and ejects the device at the specified path.

```
func unmountAndEjectDevice(atPath path: String) -> Bool
```

## Parameters

`path`

The path to the device.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the system unmounted the device; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

When this method begins, it posts an [`willUnmountNotification`](/documentation/AppKit/NSWorkspace/willUnmountNotification) to the `NSWorkspace` object’s notification center. When it is finished, it posts an [`didUnmountNotification`](/documentation/AppKit/NSWorkspace/didUnmountNotification).

Prefer the [`unmountAndEjectDevice(at:)`](/documentation/AppKit/NSWorkspace/unmountAndEjectDevice(at:)) method because it provides more detailed error information.

You can safely call this method from any thread of your app.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)