---
title: "searchBar(_:selectedScopeButtonIndexDidChange:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uisearchbardelegate/searchbar(_:selectedscopebuttonindexdidchange:)"
---

# searchBar(_:selectedScopeButtonIndexDidChange:)

Tells the delegate that the scope button selection changed.

## Declaration

```swift
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 doc://com.apple.uikit/documentation/UIKit/UISearchBar/selectedScopeButtonIndex).
