我知道如何替换字符,但是当我尝试替换这些字符\和"给我错误是否有任何办法。感谢
\和"是从键盘,但我想要更换,因为我在URL中使用,这个URL不读这个。
当我点击字符\或"在键盘xcode给我错误
代码:
// I want make some like termClean1
@IBOutlet weak var SearchBar: UISearchBar!
var term: String = "" {
didSet {
let termClean1 = term.replacingOccurrences(of: "\", with: "+")
print(" \(term)")
print("\(termClean1)")
}
}
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
self.term = searchBar.text!
}