---
title: MTLCopyAllDevicesWithObserver
framework: metal
role: symbol
role_heading: Function
path: metal/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.

## Declaration

```occ
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.

## Mentioned in

Handling external GPU additions and removals Finding multiple GPUs on an Intel-based Mac

## Discussion

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(_:) function.

## See Also

### Locating GPUs

- [Finding multiple GPUs on an Intel-based Mac](metal/finding-multiple-gpus-on-an-intel-based-mac.md)
- [Getting the GPU that drives a view’s display](metal/getting-the-gpu-that-drives-a-views-display.md)
- [MTLCopyAllDevices()](metal/mtlcopyalldevices().md)
- [MTLRemoveDeviceObserver(_:)](metal/mtlremovedeviceobserver(_:).md)
- [CGDirectDisplayCopyCurrentMetalDevice(_:)](coregraphics/cgdirectdisplaycopycurrentmetaldevice(_:).md)
- [MTLDeviceNotificationHandler](metal/mtldevicenotificationhandler.md)
- [MTLDeviceNotificationName](metal/mtldevicenotificationname.md)
