[R-SIG-Mac] Calling Objective C/Cocoa code from R

Simon Urbanek simon.urbanek at r-project.org
Thu Mar 12 20:33:25 CET 2009


On Mar 12, 2009, at 14:35 , Guillaume Chapron wrote:

> I have a simulation model (command line tool) written in Objective C/ 
> Cocoa. I would like to know if it is possible to call it from R and  
> get the results into R as well. The documentation explains how to do  
> it with C or Fortran, but I have not found anything with Objective C/ 
> Cocoa. Has anyone tried do this or do you know an example explaining  
> how?

ObjectiveC uses the same ABI as C (it's in fact just a very thin layer  
above C), so you can safely use R's C API. In addition, if you want to  
instantiate ObjC objects and pass messages (without going through  
function calls), you can use one of the ObjC packages around: Cocoa (http://www.rforge.net/Cocoa/ 
  ) or RObjectiveC (http://www.omegahat.org/RObjectiveC/ ).

All of the above assumes that you want to use that tool as a library  
(R supports ObjC in packages out of the box). If you want to just  
invoke it on the command line, you can use the regular system()  


More information about the R-SIG-Mac mailing list