write(toFile:atomically:)
Writes the data object’s bytes to the file specified by a given path.
Declaration
func write(toFile path: String, atomically useAuxiliaryFile: Bool) -> BoolParameters
- path:
The location to which to write the receiver’s bytes. If
pathcontains a tilde (~) character, you must expand it with Expandingtildeinpath before invoking this method. - useAuxiliaryFile:
If True, the data is written to a backup file, and then—assuming no errors occur—the backup file is renamed to the name specified by
path; otherwise, the data is written directly topath.
Return Value
Discussion
This method may not be appropriate when writing to publicly accessible files. To securely write data to a public location, use FileHandle instead. For more information, see Securing File Operations in Secure Coding Guide.