---
title: "stream(_:handle:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/streamdelegate/stream(_:handle:)"
---

# stream(_:handle:)

The delegate receives this message when a given event has occurred on a given stream.

## Declaration

```swift
optional func stream(_ aStream: Stream, handle eventCode: Stream.Event)
```

## Parameters

- `aStream`: The stream on which streamEvent occurred.
- `eventCode`: The stream event that occurred.

## Mentioned in

Uploading streams of data

## Discussion

Discussion The delegate receives this message only if theStream is scheduled on a run loop. The message is sent on the stream object’s thread. The delegate should examine streamEvent to determine the appropriate action it should take.

## See Also

### Related Documentation

- [Stream Programming Guide](apple-archive/documentation/Cocoa/Conceptual/Streams.md)
