【发布时间】:2018-10-24 14:25:35
【问题描述】:
我想为任何给定的字符串打开谷歌搜索,这是我的代码,但它没有打开对给定字符串的搜索。
let s = "A long-running line of '80s ads urged potential pizza customers to “avoid” what?"
let search = s.replacingOccurrences(of: " ", with: "+")
if let url = URL(string: "https://www.google.com/search?q=\(search)"), NSWorkspace.shared.open(url) {
print("default browser was successfully opened")
}
【问题讨论】: