PDA

View Full Version : Calling Objective-C Methods From JavaScript



tomalex0
1 Aug 2010, 11:05 PM
Hi,

I have came across topic in apple documentation to access Objective C methods from javascript. But i'm not sure how things are working. Did anyone tried this ?.
Could someone give more idea on this.

http://developer.apple.com/safari/library/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/ObjCFromJavaScript.html#//apple_ref/doc/uid/30001215-BBCBFJCD

DirectX
1 Aug 2010, 11:38 PM
You can call Objective C methods by invoking URL with custom protocol like document.location="mycustomprotocolname:functionName?param1=value1&param2=value2...".

Then you must catch such navigation by delegate in UIWebView and if protocol for hyperlink not "http" but "mycustomprotocolname" then parse URL and call needed functions.