Instance Method

write(toFile:options:)

Writes the bytes in the receiver to the file specified by a given path.

Declaration

func write(toFile path: String, options writeOptionsMask: NSData.WritingOptions = []) throws

Parameters

path

The location to which to write the receiver's bytes.

mask

A mask that specifies options for writing the data. Constant components are described in NSData.WritingOptions.

errorPtr

If there is an error writing out the data, upon return contains an NSError object that describes the problem.

Return Value

true if the operation succeeds, otherwise false.

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, seeSecuring File Operations in Secure Coding Guide.

See Also

Related Symbols