---
title: "add(_:forMode:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/runloop/add(_:formode:)-6z982"
---

# add(_:forMode:)

Adds a port as an input source to the specified mode of the run loop.

## Declaration

```swift
func add(_ aPort: Port, forMode mode: RunLoop.Mode)
```

## Parameters

- `aPort`: The port to add to the receiver.
- `mode`: The mode in which to add aPort. You may specify a custom mode or use one of the modes listed in Run Loop Modes.

## Discussion

Discussion This method schedules the port with the receiver. You can add a port to multiple input modes. When the receiver is running in the specified mode, it dispatches messages destined for that port to the port’s designated handler routine.

## See Also

### Managing Ports

- [remove(_:forMode:)](foundation/runloop/remove(_:formode:).md)
