Contents

OpenURLAction.Result

The result of a custom open URL action.

Declaration

struct Result

Overview

If you declare a custom OpenURLAction in the Environment, return one of the result values from its handler.

  • Use handled to indicate that the handler opened the URL.

  • Use discarded to indicate that the handler discarded the URL.

  • Use systemAction without an argument to ask SwiftUI to open the URL with the system handler.

  • Use systemAction(_:) with a URL argument to ask SwiftUI to open the specified URL with the system handler.

You can use the last option to transform URLs, while still relying on the system to open the URL. For example, you could append a path component to every URL:

.environment(\.openURL, OpenURLAction { url in
    .systemAction(url.appendingPathComponent("edit"))
})

Topics

Getting the results

Type Methods

See Also

Creating the action