I have a UILabel called "itemOneURL" which reads a URL from an external database and adds the value to this label as a string. I've got a separate button called "viewItemOne" (using a working segue) which once selected, will take the contents of the "itemOneURL" URL and open this link using the default browser.
Here is the code I am currently using to segue the button and label.
Here is the code I am currently using to segue the button and label.
Code Block @IBOutlet weak var itemOneURL: UILabel! @IBAction func viewItemOne(_ sender: UIButton) { let firstURL = itemOneURL as? String UIApplication.shared.open(URL(string:"\(firstURL)")! as URL, options: [:], completionHandler: nil) }
However, once I select this button on the UI my application doesn't do anything. Whereas when I use the following syntax elsewhere, it works and loads the URL?Code Block UIApplication.shared.open(URL(string:"https://www.apple.com")! as URL, options: [:], completionHandler: nil)
Is there something I am doing wrong which is currently causing the button to not perform any action once selected? If so, how can I rectify this and get it working please?