french english

RSS 1.0 
 
 Login 
 Password 
 Sign in 
 
26-06-08 / 01:21 : WebKit : Objective-C call from javascript (cjed)
Apple Objective-C WebKit framework (open source, and used as the Safari rendering engine) allows to call Objective-C objects from javascript. To achieve this goal these are wrapped in a WebScriptObject. This object ensures types conversions between the two languages (javascript numbers <--> NSNumber, etc.).
But you have to be warned that as expected, it is only possible from a Cocoa application context (that is MacOSX only), as the WebScriptObject has to be retrieved from a (Cocoa) WebView (by sending it the windowScriptObject message and then by binding in this object the Objective-C objects to keys, in order to make them accessible from javascript functions).
So this is only useful for Cocoa applications that use script plugins, and that must talk with these. This is the same principle as JavaBridge (now deprecated) or Objective-C call from Python and Ruby.
We can also do the opposite way, ie calling javascript (or any other scripting language) from Objective-C.
We can read an article about these features on the site vacuous virtuoso, and grab an example on Apple ADC site.
Comments
Write a comment 
  
    
  image de securisation du formulaire


  
      (will be added after validation)