Instance Method

trashItemAtURL:resultingItemURL:error:

Moves an item to the trash.

Declaration

- (BOOL)trashItemAtURL:(NSURL *)url resultingItemURL:(NSURL * _Nullable *)outResultingURL error:(NSError * _Nullable *)error;

Parameters

url

The item to move to the trash.

outResultingURL

On input, a pointer to a URL object. On output, this pointer is set to the item’s location in the trash. The actual name of the item may be changed when moving it to the trash, so use this URL to access it. You may specify nil for this parameter if you do not want the information.

error

On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

Return Value

YES if the item at url was successfully moved to the trash, or NO if the item was not moved to the trash.

Discussion

See Also

Creating and Deleting Items

createDirectoryAtURL:withIntermediateDirectories:attributes:error:

Creates a directory with the given attributes at the specified URL.

createDirectoryAtPath:withIntermediateDirectories:attributes:error:

Creates a directory with given attributes at the specified path.

createFileAtPath:contents:attributes:

Creates a file with the specified content and attributes at the given location.

removeItemAtURL:error:

Removes the file or directory at the specified URL.

removeItemAtPath:error:

Removes the file or directory at the specified path.

replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error:

Replaces the contents of the item at the specified URL in a manner that insures no data loss occurs.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software