<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISearchBarDelegate/searchBar(_:textDidChange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UISearchBarDelegate(im)searchBar:textDidChange:"
  },
  "title" : "searchBar(_:textDidChange:)"
}
-->

# searchBar(_:textDidChange:)

Tells the delegate that the user changed the search text.

```
optional func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String)
```

## Parameters

`searchBar`

The search bar that is being edited.

`searchText`

The current text in the search text field.

## Discussion

This method is also invoked when text is cleared from the search text field.

---

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)