I\'m using the UISearchBar (but not the SearchDisplayController that\'s typically used in conjunction) and I\'d like to dismiss the keyboard when you hit the \'X\' button.>
Credit to Maxhs for original answer : This is swift 2.2 version : Work like charm for me
if searchBar.text == "" { dispatch_async(dispatch_get_main_queue(), { self.searchBar.resignFirstResponder() }) }