<!--
{
  "availability" : [
    "macOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSearchToolbarItem/endSearchInteraction()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSearchToolbarItem(im)endSearchInteraction"
  },
  "title" : "endSearchInteraction()"
}
-->

# endSearchInteraction()

Ends a search interaction by giving up the first responder and adjusting the size of the search field to the available width for the toolbar item if necessary.

```
func endSearchInteraction()
```

## Discussion

Use [`beginSearchInteraction()`](/documentation/AppKit/NSSearchToolbarItem/beginSearchInteraction()) and [`endSearchInteraction()`](/documentation/AppKit/NSSearchToolbarItem/endSearchInteraction()) to programmatically control a search.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)