title: Swift : how to show error message in webview when there is no internet connection?
body: <p>I made this webview and I want to show an error message when there is no internet connection or losing internet connection, while using the app.</p>
  
  <p>This is my code:</p>
  
  <pre><code>import UIKit
  
  
  class FirstViewController: UIViewController, UIWebViewDelegate {
  
      @IBOutlet weak var webView1: UIWebView!
  
      var refreshControl:UIRefreshControl?
  
      @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          webView1.delegate = self
  
  
          let url = URL(string: "https://pharmacyuni.blogspot.com")
          webView1.loadRequest(URLRequest(url: url!))
      }
  
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      @IBAction func goBack(_ sender: Any) {
          webView1.goBack()
      }
  
  
      func webViewDidStartLoad(_ webView: UIWebView)
      {
          activityIndicator.startAnimating()
      }
      func webViewDidFinishLoad(_ webView: UIWebView)
      {
          activityIndicator.stopAnimating()
      }
  
  
      @IBAction func refreshButton(_ sender: Any) {
          webView1.reload()
      }
  
  }
  </code></pre>