---
title: "schedule(in:forMode:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmachport/schedule(in:formode:)"
---

# schedule(in:forMode:)

Schedules the receiver into the run loop mode mode of runLoop.

## Declaration

```swift
func schedule(in runLoop: RunLoop, forMode mode: RunLoop.Mode)
```

## Parameters

- `runLoop`: The run loop to which to add the receiver.
- `mode`: The run loop mode in which to add the receiver.

## Discussion

Discussion When the receiver is scheduled, the run loop monitors the mach port for incoming messages and, when a message arrives, invokes the delegate method handleMachMessage(_:).

## See Also

### Scheduling the Port on a Run Loop

- [remove(from:forMode:)](foundation/nsmachport/remove(from:formode:).md)
