Created
December 12, 2011 17:35
-
-
Save psineur/1468281 to your computer and use it in GitHub Desktop.
UIWebView with js Debugger.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @class UIWebViewWithDebug UIWebView with additional js error on DEBUG. | |
* Tested on iPad with 4.3.5 & 5.0 | |
*/ | |
@interface UIWebViewWithDebug : UIWebView {} @end | |
#ifdef DEBUG | |
@class WebView; | |
@class WebScriptCallFrame; | |
@class WebFrame; | |
@interface WebView | |
- (void) setScriptDebugDelegate: (id) delegate; | |
@end | |
@interface WebScriptCallFrame | |
- (NSString *) functionName; | |
@end | |
#endif | |
@implementation UIWebViewWithDebug | |
#ifdef DEBUG | |
#warning Potential Reject | |
- (void) webView: (WebView *) webView | |
exceptionWasRaised: (WebScriptCallFrame *) frame | |
sourceId: (int) sid | |
line: (int) line | |
forWebFrame: (WebFrame *) webFrame | |
{ | |
NSString *url = [self.request.URL absoluteString]; | |
NSString *errorString = [NSString stringWithFormat: @"Exception at %@, in function: %@ line: %@", url , [frame functionName], [NSNumber numberWithInt: line]]; | |
NSLog(errorString); | |
} | |
- (void) webView: (id) sender didClearWindowObject: (id) windowObject forFrame: (WebFrame*) frame | |
{ | |
[sender setScriptDebugDelegate: self]; | |
} | |
#endif | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment