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

# searchBar(_:selectedScopeButtonIndexDidChange:)

Tells the delegate that the scope button selection changed.

```
optional func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int)
```

## Parameters

`searchBar`

The search bar that was tapped.

`selectedScope`

The index of the selected scope button (see [`selectedScopeButtonIndex`](/documentation/UIKit/UISearchBar/selectedScopeButtonIndex)).

## Discussion

---

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)