<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NEDNSProxyManager/saveToPreferences(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NEDNSProxyManager(im)saveToPreferencesWithCompletionHandler:"
  },
  "title" : "saveToPreferences(completionHandler:)"
}
-->

# saveToPreferences(completionHandler:)

Saves the DNS proxy configuration in the caller’s DNS proxy preferences.

```
func saveToPreferences(completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`completionHandler`

A block called when the save operation completes. If the operation fails, an error instance passed to this block describes the problem. Otherwise, the error is `nil`. See [`NEDNSProxyManagerError`](/documentation/NetworkExtension/NEDNSProxyManagerError) for the list of possible errors.

## Discussion

If you alter the DNS proxy configuration that you load into the proxy manager’s properties using a call to the [`loadFromPreferences(completionHandler:)`](/documentation/NetworkExtension/NEDNSProxyManager/loadFromPreferences(completionHandler:)) method, you must then call the [`saveToPreferences(completionHandler:)`](/documentation/NetworkExtension/NEDNSProxyManager/saveToPreferences(completionHandler:)) method to make the changes take effect. Saving also stores the modified configuration for the next time the proxy is started or the configuration loaded.

Trying to save preferences before loading them produces an error.

If the DNS proxy is enabled, it becomes active as a result of this call.

---

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)