<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.13.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLCopyAllDevicesWithObserver",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:@F@MTLCopyAllDevicesWithObserver"
  },
  "title" : "MTLCopyAllDevicesWithObserver"
}
-->

# MTLCopyAllDevicesWithObserver

Returns an array of all the Metal GPU devices in the system and registers a notification handler that Metal calls when the device list changes.

```
extern NSArray<id<MTLDevice>> *MTLCopyAllDevicesWithObserver(id<NSObject>*observer, MTLDeviceNotificationHandler handler);
```

## Parameters

`observer`

A pointer to an object instance the method sets to a new observer — which Metal retains — before returning.

`handler`

A notification handler you implement that Metal calls when the system adds or removes a GPU device from the system.

## Discussion

Keep a copy of `observer` in your app after this function returns in case you want to stop receiving notifications. You can stop receiving notifications by passing `observer` to the [`MTLRemoveDeviceObserver(_:)`](/documentation/Metal/MTLRemoveDeviceObserver(_:)) function.

---

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)