For my specific problem, I ended up implementing the following scriptobject in my object. This allows me to compare strings with the function name and use the passed array. Ideally, you need to do some type checking of the arguments in the array ...
(id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args { //NSLog(@" debug WABridge invokeUndefinedMethodFromWebScrip dump name: %@", name); //NSLog(@" debug WABridge invokeUndefinedMethodFromWebScript args: %@", args); if ([name isEqualToString:@"javascriptToCWithArgs"]) { std::vector<std::wstring> dataArray; dataArray.reserve([args count]); for (id object in args) { std::wstring valAsWstring = NSStringToStringW(object); //place into vector dataArray.push_back(valAsWstring); } //callback into my code if (m_pWebView!= nil) { m_pWebView->m_pObjectiveCWebViewWrapper->getWebViewListener()->onMessageFromPageWithArgs(dataArray); } } else { NSLog(@"Bridge undefined/unsupported function"); } return nil; }
chris source share