I have an UIWebView
with my application and want to call Objective-C
method from JavaScript.
All documentation and tutorial that I found, I see is just uses the windowScriptObject
method, but in my code Xcode
says that webView dont have instance method -windowScriptObject
.
What's wrong?
- (void)viewDidLoad
{
[super viewDidLoad];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
NSString *indexPath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www"];
NSURL *url = [NSURL fileURLWithPath:indexPath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[self.view addSubview:webView];
id win = [webView windowScriptObject]; // In this line, Xcode alert 'Instance method "-windowScriptObject" not found'
[win setValue:@"yes" forKey:@"isExtended"];
}
windowScriptObject
seems not to be available on iOS. ReferenceAlso, check similar question: how to use windowScriptObject on the iPhone?