item(at:willMoveTo:)
Announces that your app is moving a file to a new URL.
Declaration
func item(at oldURL: URL, willMoveTo newURL: URL)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 item(at:didMoveTo:) 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
coordinate(readingItemAt:options:error:byAccessor:)coordinate(writingItemAt:options:error:byAccessor:)coordinate(readingItemAt:options:writingItemAt:options:error:byAccessor:)coordinate(writingItemAt:options:writingItemAt:options:error:byAccessor:)prepare(forReadingItemsAt:options:writingItemsAt:options:error:byAccessor:)item(at:didMoveTo:)cancel()