iosiphonexcodeswift5

Open URL Only Works in Main Storyboard View Controller, Will Not Work in the Multiple Screen View Controllers


I have a single storyboard with 4 screens (segue to each ViewControllers).

An Open Url sequence WILL NOT WORK on any of the additional 3 screen ViewControllers. It only works on the main View Controller or on a separate storyboard (manual segue).

The View Controllers were created using Cocoa Touch Class: UIViewController.

Throws this error: Thread 1: "[<UIViewController 0x10b318630> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key WebButton."

I've wiped all possible stray connections.

This code works perfectly fine ONLY on the main and separate storyboards:

@IBAction func GoToWebsite(_ sender: UIButton)  {
        
        if let url = URL(string: "https://www.google.com") {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
            
        }
    }

I am missing some bit of information... Thank you.


Solution

  • SOLVED I deleted the three ScreenControllers and started again. This time, it worked.

     ¯\_(ツ)_/¯