fileMover

Presents a system dialog for allowing the user to move an existing file to a new location.

View ModifieriOS 14.0+macOS 11.0+

Overloads

4 ways to call compose().fileMover(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().fileMover({
  isPresented: Binding<boolean>,
  file: string | null,
  onCompletion: (result: SwiftResult<string>) => void,
})
Swift
nonisolated func fileMover(
    isPresented: Binding<Bool>,
    file: URL?,
    onCompletion: @escaping (Result<URL, any Error>) -> Void
) -> some View

Parameters

  • options.isPresented*Binding<boolean>

    A binding to whether the dialog should be shown.

  • options.file*string | null

    The URL of the file to be moved.

  • options.onCompletion*(result: SwiftResult<string>) => void

    A callback that will be invoked when the operation has has succeeded or failed. To access the received URLs, call startAccessingSecurityScopedResource. When the access is no longer required, call stopAccessingSecurityScopedResource. - term result: A Result indicating whether the operation succeeded or failed.

Discussion

In order for the dialog to appear, both isPresented must be true and file must not be nil. When the operation is finished, isPresented will be set to false before onCompletion is called. If the user cancels the operation, isPresented will be set to false and onCompletion will not be called.

To further configure the dialog's appearance and behavior, use these view modifiers: fileDialogDefaultDirectory(_:), fileDialogConfirmationLabel(_:), fileDialogMessage(_:), fileDialogBrowserOptions(_:), fileDialogURLEnabled(_:), fileDialogImportsUnresolvedAliases(_:), and fileDialogCustomizationID(_:).

See also

More in Drag and drop.