Use WKWebView with Key-Value Observing (KVO)

Here I am using WKWeb view with observer value to check that web is loading or not ???

I have to manage loader until the web view is loading, so for that I have put observer on web view boolean value loading.

Just simple take web view and add observer :

for @objc “ KVO isn’t terribly nice in pure Swift code, because it relies on the Objective-C runtime — you need to use @objc classes that inherit from NSObject

Add method for observer

So like that in mange indicator you can…and you can also mange for
GoForward , GoBack with this observer and you can make UI changes accordingly.

And in last just remove observer :

And that’s it!!!!!!




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store