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

# schedule(in:forMode:)

Adds the service to the specified run loop.

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

## Parameters

`aRunLoop`

The run loop to which to add the receiver.

`mode`

The run loop mode to which to add the receiver. Possible values for `mode` are discussed in the “Constants” section of [`RunLoop`](/documentation/Foundation/RunLoop).

## Discussion

You can use this method in conjunction with [`remove(from:forMode:)`](/documentation/Foundation/NetService/remove(from:forMode:)) to transfer a service to a different run loop. You should not attempt to run a service on multiple run loops.

---

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)