webView.loadRequest(urlRequest) shows use of unresolved identifier

Asked 2 years ago, Updated 2 years ago, 26 views

import UIKit

classViewController:UIViewController {
    @IBOutlet weak var webview:UIWebView!
    @IBOutlet weak var searchBar: UIBarButtonItem!
    @IBOutlet weak var Stop: UIBarButtonItem!
    @IBOutlet weak var Reload: UIBarButtonItem!
    @IBOutlet weak var Back: UIBarButtonItem!

    // Page to open at startup
    let homeUrlString="https://www.google.co.jp/"

    override func viewDidLoad(){
        super.viewDidLoad()
        // open a website
        open(urlString:homeUrlString)
    }

    // Open the specified url in web view
    funcopen(urlString:String){
        let url = URL (string: urlString)
        let urlRequest=URLRequest(url:url!)
        WebView.loadRequest (urlRequest)
    }

    @ IBAction func BackButtonTapped (sender: UIBarButtonItem) {

    }
    @ IBAction func reloadButtonTapped (sender: UIBarButtonItem) {

    }

    @ IBAction func stopButtonTapped (sender: UIBarButtonItem) {

    }
}

WebView.loadRequest(urlRequest) shows use of unresolved identifier and I don't know what's wrong.I'm a beginner and I'm following the reference book, and it looks like this...
Someone please tell me what's wrong.
The language is Swift

swift

2022-09-29 20:28

1 Answers

The W and V in WebView in WebView.loadRequest(urlRequest) are capitalized.

@IBOutletweakvar webview:UIWebView! defines all lowercase letters as webview and must be written the same way.Swift is case sensitive and interprets it as a different variable.

Therefore, the error unresolved identifier is trying to use an undefined property.


2022-09-29 20:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.