How to load URL in UIWebView in Swift?

前端 未结 18 1469
南旧
南旧 2020-11-29 00:58

I have the following code:

UIWebView.loadRequest(NSURLRequest(URL: NSURL(string: \"google.ca\")))

I am getting the following error:

18条回答
  •  庸人自扰
    2020-11-29 01:13

    Swift 3 doesn't use NS prefix anymore on URL and URLRequest, so the updated code would be:

    let url = URL(string: "your_url_here")
    yourWebView.loadRequest(URLRequest(url: url!))
    

提交回复
热议问题