I was looking for a method to debug JavaScript in UIWebView and came across some articles about _enableRemoteInspector specifically
http://atnan.com/blog/2011/11/17/enabling-remote-debugging-via-private-apis-in-mobile-safari/
I could not get the example code to compile 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 compile
//[NSClassFromString(@"WebView") _enableRemoteInspector];
}
So I tried performSelector and that works and the debugger works as described.
But how do you compile it without resorting to performSelector?
I am running Xcode 4.2.1 and my project uses the iOS5 SDK.
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 becomes an error. If you want it to compile without using performSelector
you'll need to disable ARC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With