Creates a file with the specified content and attributes at the given location.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The path for the new file.
A data object containing the contents of the new file.
A dictionary containing the attributes to associate with the new file. You can use these attributes to set the owner and group numbers, file permissions, and modification date. For a list of keys, see
NSFile. If you specify
attributes, the file is created with a set of default attributes.
YES if the operation was successful or if the item already exists, otherwise
If you specify
nil for the
attributes parameter, this method uses a default set of values for the owner, group, and permissions of any newly created directories in the path. Similarly, if you omit a specific attribute, the default value is used. The default values for newly created files are as follows:
Permissions are set according to the umask of the current process. For more information, see umask.
The owner ID is set to the effective user ID of the process.
The group ID is set to that of the parent directory.
If a file already exists at
path, this method overwrites the contents of that file if the current process has the appropriate privileges to do so.