I am new to Xcode and downloaded the last 9.2 version, I am trying to insert a link to the web in a button and is not functioning. Here is the code. link not working
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func button(_ sender: Any) {
if let url = URL(string: "https://www.youtube.com/watch?v=UPfA3mUfvGA&t=90s") {
UIApplication.shared.canOpenURL(url)
UIApplication.shared.open(url, options: [:], completionHandler:nil)
}
}
}
When you press Guorlin Premium button it takes you to a website
Now, when I press the Guorlin Premium button is not working, it does not take me to the website.
Just press
option+shift+command+k
and pressOk
to clean the folder and try to run it on a real device instead of the simulator.It definitely works, I had a similar problem with a similar code and it worked for me. No change in code is needed.