<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURLConnection/schedule(in:forMode:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLConnection(im)scheduleInRunLoop:forMode:"
  },
  "title" : "schedule(in:forMode:)"
}
-->

# schedule(in:forMode:)

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

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

## Parameters

`aRunLoop`

The [`RunLoop`](/documentation/Foundation/RunLoop) instance to use when calling delegate methods.

`mode`

The mode in which to call delegate methods.

## 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:)`](/documentation/Foundation/NSURLConnection/init(request:delegate:startImmediately:)) method and provide <doc://com.apple.documentation/documentation/Swift/false> for the `startImmediately` parameter, you can schedule the connection on a different run loop or mode before starting it with the [`start()`](/documentation/Foundation/NSURLConnection/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(_:)`](/documentation/Foundation/NSURLConnection/setDelegateQueue(_:)) method.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)