I'm trying to run this function when a button is tapped:
@IBAction func openLink(_ sender: UIButton) {
let link1 = "https://www.google.com/#q="
let link2 = birdName.text!
let link3 = link2.replacingOccurrences(of: " ", with: "+") //EDIT
let link4 = link1+link3
guard
let query = link4.addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed),
let url = NSURL(string: "https://google.com/#q=(query)")
else { return }
UIApplication.shared.openURL(URL(url))
}
However, the last line is flagged as "cannot call value of non-function type "UIApplication". This syntax is from here, so I'm not sure whats going on.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…