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

# schedule(in:forMode:)

Determines the run loop and mode that the connection uses to call methods on its delegate.

## Declaration

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

## Parameters

- `aRunLoop`: The doc://com.apple.foundation/documentation/Foundation/RunLoop instance to use when calling delegate methods.
- `mode`: The mode in which to call delegate methods.

## Discussion

Discussion By default, a connection is scheduled on the current thread in the default mode when it is created. If you create a connection with the init(request:delegate:startImmediately:) method and provide false for the startImmediately parameter, you can schedule the connection on a different run loop or mode before starting it with the start() method. You can schedule a connection on multiple run loops and modes, or on the same run loop in multiple modes. You cannot reschedule a connection after it has started. It is an error to schedule delegate method calls with both this method and the setDelegateQueue(_:) method.

## See Also

### Scheduling Delegate Method Calls

- [setDelegateQueue(_:)](foundation/nsurlconnection/setdelegatequeue(_:).md)
- [unschedule(from:forMode:)](foundation/nsurlconnection/unschedule(from:formode:).md)
