Dmitry Isaev
Dmitry Isaev

Reputation: 3998

How to open Web Inspector on 10.12 Sierra?

This works in OS X:

WebPreferences *prefs = [webView preferences];
[prefs setDeveloperExtrasEnabled:YES];

WebInspector *inspector = [[WebInspector alloc] initWithWebView:webView];

But crashes in macOS:

-[WebInspector initWithWebView:]: unrecognized selector sent to instance 0xb1ab1ab1a

Is this Private API thrown out?

The code is taken from here.

Upvotes: 1

Views: 295

Answers (1)

Dmitry Isaev
Dmitry Isaev

Reputation: 3998

They've renamed it: http://trac.webkit.org/changeset/189654

TLDR:

WebInspector *inspector = [WebInspector alloc];

if ([inspector respondsToSelector:@selector(initWithWebView:)])
    [inspector initWithWebView:webView];
else
    [inspector initWithInspectedWebView:webView];

In case of future changes, just look at the WebKit source code.

Upvotes: 2

Related Questions