Instance Method

itemAtURL:willMoveToURL:

Announces that your app is moving a file to a new URL.

Declaration

- (void)itemAtURL:(NSURL *)oldURL willMoveToURL:(NSURL *)newURL;

Parameters

oldURL

The old location of the file or directory.

newURL

The new location of the file or directory.

Discussion

This method is intended for apps that adopt App Sandbox.

Some apps need to rename files while saving them. For example, when a user adds an attachment to a rich text document, TextEdit changes the document’s filename extension from .rtf to .rtfd. In such a case, in a sandboxed app, you must call this method to declare your intent to rename a file without user approval.

After the renaming process succeeds, call the itemAtURL:didMoveToURL: method, with the same arguments, to provide your app with continued access to the file under its new name, while also giving up access to any file that appears with the old name.

If your macOS app is not sandboxed, this method serves no purpose. This method is nonfunctional in iOS.

See Also

Coordinating File Operations Synchronously

coordinateReadingItemAtURL:options:error:byAccessor:

Initiates a read operation on a single file or directory using the specified options.

coordinateWritingItemAtURL:options:error:byAccessor:

Initiates a write operation on a single file or directory using the specified options.

coordinateReadingItemAtURL:options:writingItemAtURL:options:error:byAccessor:

Initiates a read operation that contains a follow-up write operation.

coordinateWritingItemAtURL:options:writingItemAtURL:options:error:byAccessor:

Initiates a write operation that involves a secondary write operation.

prepareForReadingItemsAtURLs:options:writingItemsAtURLs:options:error:byAccessor:

Prepare to read or write from multiple files in a single batch operation.

itemAtURL:didMoveToURL:

Notifies relevant file presenters that the location of a file or directory changed.

cancel

Cancels any active file coordination calls.