func callAsFunction (URL, completion: (Bool) -> Void)
Asynchronously opens a URL, following system conventions.
Availability 有効性
Technology
func callAsFunction(_ url: URL
)
url
The URL to open.
Don’t call this method directly. SwiftUI calls it when you call the Open
structure that you get from the Environment
, using a URL as an argument:
struct OpenURLExample: View {
private var openURL (\.openURL)
var body: some View {
Button {
if let url = URL(string: "https://www.example.com") {
openURL(url) // Implicitly calls openURL.callAsFunction(url)
}
} label: {
Label("Get Help", systemImage: "person.fill.questionmark")
}
}
}
For information about how Swift uses the call
method to simplify call site syntax, see Methods with Special Names in The Swift Programming Language.
func callAsFunction (URL, completion: (Bool) -> Void)