---
title: delegate
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/stream/delegate
---

# delegate

Sets the receiver’s delegate.

## Declaration

```swift
unowned(unsafe) var delegate: (any StreamDelegate)? { get set }
```

## Parameters

- `delegate`: The delegate for the receiver.

## Discussion

Discussion By default, a stream is its own delegate, and subclasses of NSInputStream and NSOutputStream must maintain this contract. If you override this method in a subclass, passing nil must restore the receiver as its own delegate. Delegates are not retained. To learn about delegates and delegation, read “Delegation” in Cocoa Fundamentals Guide.

## See Also

### Configuring Streams

- [property(forKey:)](foundation/stream/property(forkey:).md)
- [setProperty(_:forKey:)](foundation/stream/setproperty(_:forkey:).md)
