Question: I have this code:

```swift
extension VC : UISearchBarDelegate
{
    func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
        print("searchBarTextDidEndEditing")
    }

    func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
        // searchBar.resignFirstResponder()
    }
}

```

`searchBarCancelButtonClicked` has fired when clicked on search , but `searchBarTextDidEndEditing` has not fire until I call `searchBar.resignFirstResponder()`

I read a lot of questions and answers about that, but I did not understand why is that happen, and what is `resignFirstResponder()` do here?

Answer: 
As stated in the [documents](https://developer.apple.com/documentation/uikit/uiresponder/1621097-resignfirstresponder) `resignFirstResponder` 

> 
> Notifies this object that it has been asked to relinquish its status as first responder in its window.
> 
> 
> 

Basically this function call tells your input field that it should not be getting any more inputs from the user or the input action is finished for this input field. Thus your `searchBarTextField` ends it's editing status and `searchBarTextDidEndEditing` is called. 

If you'd like to learn more about what a `firstResponder` is then you may want to checkout this [part](https://developer.apple.com/documentation/appkit/nswindow/1419440-firstresponder) of the documentation.
This may be useful to some like myself wondering why similar delegate methods are not firing. Check you have set up all appropriate delegates for example:

```
    searchController.searchResultsUpdater = self
    searchController.searchBar.delegate = self

```