---
title: "write(to:atomically:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsarray/write(to:atomically:)"
---

# write(to:atomically:)

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

## Declaration

```swift
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

Return Value true if the location is written successfully, otherwise false.

## Discussion

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

### Storing Arrays

- [write(toFile:atomically:)](foundation/nsarray/write(tofile:atomically:).md)
