<!--
{
  "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/remove(from:forMode:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSNetService(im)removeFromRunLoop:forMode:"
  },
  "title" : "remove(from:forMode:)"
}
-->

# remove(from:forMode:)

Removes the service from the given run loop for a given mode.

```
func remove(from aRunLoop: RunLoop, forMode mode: RunLoop.Mode)
```

## Parameters

`aRunLoop`

The run loop from which to remove the receiver.

`mode`

The run loop mode from which to remove 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 [`schedule(in:forMode:)`](/documentation/Foundation/NetService/schedule(in:forMode:)) to transfer the service to a different run loop. Although it is possible to remove an `NSNetService` object completely from any run loop and then attempt actions on it, it is an error to do so.

---

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)