write(toFile:atomically:)
Writes the contents of the array to a file at a given path.
Declaration
func write(toFile path: String, atomically useAuxiliaryFile: Bool) -> BoolParameters
- path:
The path at which to write the contents of the array.
If
pathcontains a tilde (~) character, you must expand it with Expandingtildeinpath before invoking this method. - useAuxiliaryFile:
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 topath. The True option guarantees thatpath, if it exists at all, won’t be corrupted even if the system should crash during writing.
Return Value
Discussion
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.