Instance Method インスタンスメソッド

callAsFunction()

Dismisses the current search operation, if any.

Declaration 宣言

func callAsFunction()

Discussion 議論

Don’t call this method directly. SwiftUI calls it for you when you call the DismissSearchAction structure that you get from the Environment:


private struct SearchedView: View {
    @Environment(\.dismissSearch) private var dismissSearch


    var body: some View {
        Button("Cancel") {
            dismissSearch() // Implicitly calls dismissSearch.callAsFunction()
        }
    }
}

For information about how Swift uses the callAsFunction() method to simplify call site syntax, see Methods with Special Names in The Swift Programming Language.