<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSColorList/write(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSColorList(im)writeToURL:error:"
  },
  "title" : "write(to:)"
}
-->

# write(to:)

Saves the color list to the file at the specified URL.

```
func write(to url: URL?) throws
```

## Parameters

`url`

The URL at which to store the color list. The URL must specify either a directory or file in the file system. Specify `nil` to save the color list to the user’s `~/Library/Colors` directory.

## Discussion

If `url` represents a directory, this method saves the color list in that directory in a file with the name *<name>*`.clr`, where *<name>* is the value of the [`name`](/documentation/AppKit/NSColorList/name-swift.property) property. If `url` represents a file, this method saves the color list using the name you provided.

---

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)