SwiftUI Journey Part 9: WKNavigationDelegate
Next on the task is how to extend the class WKNavigationDelegate
so I can call the evaluateJavascript() function.
We used an ' extension' in our existing iOS app using UIKit
. But I found out, that this won’t work when using SwiftUI.
|
|
After further Googling, research and internet digging I learned that I need to use makeCoordinator() function.
Creates the custom instance that you use to communicate changes from your view controller to other parts of your SwiftUI interface.
First, I wrote an inner class called Coordinator
.
|
|
Then in the main class
|
|
This implementation feels a little hacky. Why wouldn’t Apple just introduce a WebView
for SwiftUI? Going through all this is just painful.