title: How to fix black screen in load of webview url from my own class
body: <p>I am creating one SDK to get the url from user and load. So ai m creating my own class with <code>WKWebview</code>. But i am getting few issues about Instance member <code>webView</code> cannot be used on type <code>MyWebView(UIview)</code></p>
  <p>My code :</p>
  <pre><code>import Foundation
  import WebKit
  
  public class MyWebView: UIView, WKNavigationDelegate {
  
      // initialize the view
       var webView: WKWebView!
  
      // get the url and load the page
      public func passUrl(url: String) {
          guard let url = URL(string: url) else { return }
          webView = WKWebView()
          webView.navigationDelegate = self
          webView.load(URLRequest(url: url))
          webView.allowsBackForwardNavigationGestures = true
          webView.addObserver(self, forKeyPath: &quot;URL&quot;, options: .new, context: nil)
      }
      
      // Observe value
      override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
          if let key = change?[NSKeyValueChangeKey.newKey] {
              print(&quot;URL Changes: \(key)&quot;)
              let alert = UIAlertController(title: &quot;URL Changed&quot;, message: &quot;\(key)&quot;, preferredStyle: .alert)
              alert.addAction(UIAlertAction(title: &quot;Yes&quot;, style: .default, handler: nil))
              alert.addAction(UIAlertAction(title: &quot;No&quot;, style: .cancel, handler: nil))
              self.window?.rootViewController?.present(alert, animated: true, completion: nil)
          }
      }
      
  }
  </code></pre>
  <p>My view controller :</p>
  <pre><code>class ViewController: UIViewController {
  
      var webView =  MyWebView()
      
  
      override func viewDidLoad() {
          super.viewDidLoad()
          view = webView
          webView.passUrl(url: &quot;https://www.swiggy.com&quot;)
      }
  }
  </code></pre>
  <p>When i run, i am getting my screen as black. Not sure what i am doing wong. Any help would be great.</p>
  <p>Thanks</p>