 import WebKit
 
 public class WKWebViewEx: WKWebView, WebViewProtocol, WKNavigationDelegate {
+    
+    private let context = UnsafeMutablePointer<Void>.alloc(1)
+    private let kEstimatedProgress = "estimatedProgress"
     
     //替代WKNavigationDelegate，用于获取页面加载的生命周期
     public weak var webViewNavigationDelegate: WebViewNavigationDelegate?

    public override init(frame: CGRect, configuration: WKWebViewConfiguration) {
        super.init(frame: frame, configuration: configuration)
        self.navigationDelegate = self
        self.addObserver(self, forKeyPath: "estimatedProgress", options: .New, context: nil)
    }
    
    required public init?(coder: NSCoder) {

    }
    
    deinit {
        self.navigationDelegate = nil
        self.removeObserver(self, forKeyPath: self.kEstimatedProgress, context: self.context)
    }
    
    public override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
        if keyPath == self.kEstimatedProgress {
            self.webViewNavigationDelegate?.webViewLoadingWithProgress(self, progress: self.estimatedProgress)
        }
    }
