Writes the contents of the receiver to a file at a given path using a given encoding.
- iOS 2.0+
- macOS 10.4+
- UIKit for Mac 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
The file to which to write the receiver. If
pathcontains a tilde (
~) character, you must expand it with
expandingbefore invoking this method.
Tilde In Path
true, the receiver is written to an auxiliary file, and then the auxiliary file is renamed to
false, the receiver is written directly to
trueoption guarantees that
path, if it exists at all, won’t be corrupted even if the system should crash during writing.
The encoding to use for the output. For possible values, see
If there is an error, upon return contains an
NSErrorobject that describes the problem. If you are not interested in details of errors, you may pass in
true if the file is written successfully, otherwise
false (if there was a problem writing to the file or with the encoding).
This method overwrites any existing file at
This method stores the specified encoding with the file in an extended attribute under the name
com. The value contains the IANA name for the encoding and the
CFString value for the encoding, separated by a semicolon. The
CFString value is written as an ASCII string containing an unsigned 32-bit decimal integer and is not terminated by a null character. One or both of these values may be missing. Examples of the value written include the following:
string use this information to open the file using the right encoding.