---
title: "callAsFunction(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/openurlaction/callasfunction(_:)"
---

# callAsFunction(_:)

Opens a URL, following system conventions.

## Declaration

```swift
@MainActor @preconcurrency func callAsFunction(_ url: URL)
```

## Parameters

- `url`: The URL to open.

## Discussion

Discussion Don’t call this method directly. SwiftUI calls it when you call the OpenURLAction structure that you get from the Environment, using a URL as an argument: struct OpenURLExample: View {     @Environment(\.openURL) private var 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 callAsFunction() method to simplify call site syntax, see Methods with Special Names in The Swift Programming Language.

## See Also

### Calling the action

- [callAsFunction(_:completion:)](swiftui/openurlaction/callasfunction(_:completion:).md)
