Instance Method


Writes the contents of the array to a file at a given path.


func write(toFile path: String, atomically useAuxiliaryFile: Bool) -> Bool



The path at which to write the contents of the array.

If path contains a tilde (~) character, you must expand it with expandingTildeInPath before invoking this method.


If true, the array is written to an auxiliary file, and then the auxiliary file is renamed to path. If false, the array is written directly to path. The true option guarantees that path, if it exists at all, won’t be corrupted even if the system should crash during writing.

Return Value

true if the file is written successfully, otherwise false.


If the array’s contents are all property list objects (NSString, NSData, NSArray, or NSDictionary objects), the file written by this method can be used to initialize a new array with the class method arrayWithContentsOfFile: or the instance method init(contentsOfFile:). This method recursively validates that all the contained objects are property list objects before writing out the file, and returns false if all the objects are not property list objects, since the resultant file would not be a valid property list.

See Also

Storing Arrays

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

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