<!--
{
  "availability" : [
    "iOS: 2.0.0 - 27.0.0",
    "iPadOS: 2.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.0.0 - 27.0.0",
    "tvOS: 9.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 2.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSArray/write(to:atomically:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSArray(im)writeToURL:atomically:"
  },
  "title" : "write(to:atomically:)"
}
-->

# write(to:atomically:)

Writes the contents of the array to the location specified by a given URL.

```
func write(to url: URL, atomically: Bool) -> Bool
```

## Parameters

`url`

The location at which to write the array.

`atomically`

If <doc://com.apple.documentation/documentation/Swift/true>, the array is written to an auxiliary location, and then the auxiliary location is renamed to `aURL`. If <doc://com.apple.documentation/documentation/Swift/false>, the array is written directly to `aURL`. The <doc://com.apple.documentation/documentation/Swift/true> option guarantees that `aURL`, if it exists at all, won’t be corrupted even if the system should crash during writing.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the location is written successfully, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

If the array’s contents are all property list objects (`NSString`, `NSData`, `NSArray`, or `NSDictionary` objects), the location written by this method can be used to initialize a new array with the class method `NSArray/init(contentsOfURL:)-fk8x` or the instance method `NSArray/init(contentsOfURL:)-5lo2y`.

## See Also



---

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)