admin管理员组

文章数量:1410697

I was looking for a method to debug JavaScript in UIWebView and came across some articles about _enableRemoteInspector specifically

/

I could not get the example code to pile though. I keep getting a "No known class method for selecctor" error. Not just a warning.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //Works
    [NSClassFromString(@"WebView") performSelector:@selector(_enableRemoteInspector)];

    //Won't pile
    //[NSClassFromString(@"WebView") _enableRemoteInspector];
}

So I tried performSelector and that works and the debugger works as described.

But how do you pile it without resorting to performSelector?

I am running Xcode 4.2.1 and my project uses the iOS5 SDK.

I was looking for a method to debug JavaScript in UIWebView and came across some articles about _enableRemoteInspector specifically

http://atnan./blog/2011/11/17/enabling-remote-debugging-via-private-apis-in-mobile-safari/

I could not get the example code to pile though. I keep getting a "No known class method for selecctor" error. Not just a warning.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //Works
    [NSClassFromString(@"WebView") performSelector:@selector(_enableRemoteInspector)];

    //Won't pile
    //[NSClassFromString(@"WebView") _enableRemoteInspector];
}

So I tried performSelector and that works and the debugger works as described.

But how do you pile it without resorting to performSelector?

I am running Xcode 4.2.1 and my project uses the iOS5 SDK.

Share Improve this question asked Dec 29, 2011 at 10:13 MegasaurMegasaur 6368 silver badges20 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

This is due to the new Automatic Reference Counting (ARC) in iOS 5. The sample code you linked to makes an assumption that you're not using ARC.

If you weren't using ARC, [NSClassFromString(@"WebView") _enableRemoteInspector] would simply produce a "method not found" warning (because the method isn't declared publicly).

However, for various reasons when you've got ARC enabled this warning bees an error. If you want it to pile without using performSelector you'll need to disable ARC.

本文标签: javascriptiOS 5Compiling Private APIs for debuggingspecifically enableRemoteInspectorStack Overflow