---
title: "saveToPreferences(completionHandler:)"
framework: networkextension
role: symbol
role_heading: Instance Method
path: "networkextension/nednssettingsmanager/savetopreferences(completionhandler:)"
---

# saveToPreferences(completionHandler:)

Save your DNS settings configuration to the system networking preferences.

## Declaration

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

```swift
func saveToPreferences() async throws
```

## Parameters

- `completionHandler`: An optional block that takes an doc://com.apple.documentation/documentation/Foundation/NSError object. If specified, this block runs on your application’s main thread after the save operation completes. If an error occurs while saving the configuration, the block returns an NSError object.

## Discussion

Discussion You must call loadFromPreferences(completionHandler:) at least once before calling this method the first time after your app launches.

## See Also

### Managing DNS configurations

- [shared()](networkextension/nednssettingsmanager/shared().md)
- [loadFromPreferences(completionHandler:)](networkextension/nednssettingsmanager/loadfrompreferences(completionhandler:).md)
- [removeFromPreferences(completionHandler:)](networkextension/nednssettingsmanager/removefrompreferences(completionhandler:).md)
