@objc func searchButtonTap() {
searchBar.becomeFirstResponder()
var remove = searchBar.text
remove = String(remove!.dropLast())
searchBar.text = remove
}
Также пробовал два возврата
@objc func searchButtonTap() {
let name: String = searchBar.text!
let endIndex = name.index(name.endIndex, offsetBy: -2)
let truncated = String(name[..<endIndex])
searchBar.text = truncated
}