I am trying to build a very basic browser for in-house use at my company. This is the first real code I've written in Swift, so very much a beginner and relying on tutorials. I have successfully got text to display on a second controller, and would now like to use that to load a Web View.
class ViewController: UIViewController {
@IBOutlet weak var urlField: UITextField!
@IBAction func launch(_ sender: Any) {
if urlField.text != "" {
performSegue(withIdentifier: "launch", sender: self)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let secondController = segue.destination as! BrowserController
secondController.urlString = urlField.text!
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
This is where I get lost - how can I turn that urlString into something the web view can then load?
All I have so far in the second controller is
import UIKit
import WebKit
class BrowserController: UIViewController {
@IBOutlet weak var label: UILabel!
var urlString = String()
override func viewDidLoad() {
super.viewDidLoad()
label.text = urlString
// Do any additional setup after loading the view.
}
}
Any help greatly appreciated!