How to present a web view while supporting 10.9?


John Brownie
 

My app currently supports 10.9, and I want to add a feature that displays an HTML document stored locally (in the bundle). The obvious way is to have a window which contains a web view. However, WKWebView is only available in 10.10, and WebView is deprecated.

If it were a matter of calling a method, I could wrap it with availability calls, but it's a definition of the class of an element in a window controller class. Presumably there is a way to handle this, but I haven't discovered it.

What I'm looking for is something like

if #available(macOS 10.10, *) {
    var webView: WKWebView
}
else {
    var webView: WebView
}

...but that is for running code, not declarations.

Is there a way to do this through IB? Or is my alternative to build the window in code, using whatever is available based on the runtime platform?

John
--
John Brownie
Mussau-Emira language, New Ireland Province, Papua New Guinea
Kouvola, Finland

Join cocoa@apple-dev.groups.io to automatically receive all group messages.