---
title: "setDelegate(_:queue:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avplayeritemmetadataoutput/setdelegate(_:queue:)"
---

# setDelegate(_:queue:)

Sets the delegate and a dispatch queue on which the delegate is called.

## Declaration

```swift
func setDelegate(_ delegate: (any AVPlayerItemMetadataOutputPushDelegate)?, queue delegateQueue: dispatch_queue_t?)
```

## Parameters

- `delegate`: An object conforming to doc://com.apple.avfoundation/documentation/AVFoundation/AVPlayerItemMetadataOutputPushDelegate protocol.
- `delegateQueue`: A dispatch queue on which all delegate methods will be called.

## Discussion

Discussion You specify the metadata delegate, and a dispatch queue on which it will be called, to be notified as new metadata is encountered in the source media. important: The values set for the delegate and delegateQueue arguments can be nil , but passing nil for one requires you to do the same for the other. Passing a nil value for only one argument results in an exception being raised at runtime.

## See Also

### Configuring the delegate

- [advanceIntervalForDelegateInvocation](avfoundation/avplayeritemmetadataoutput/advanceintervalfordelegateinvocation.md)
- [delegate](avfoundation/avplayeritemmetadataoutput/delegate.md)
- [AVPlayerItemMetadataOutputPushDelegate](avfoundation/avplayeritemmetadataoutputpushdelegate.md)
- [delegateQueue](avfoundation/avplayeritemmetadataoutput/delegatequeue.md)
