[R-SIG-Mac] Using Obj-C from R

Duncan Temple Lang duncan at wald.ucdavis.edu
Tue Nov 2 20:20:55 CET 2004

FWIW, I have put the original package I developed
to access ObjectiveC code from R on the Omegahat Web site


I put there in case people can make use of the code in
there to assist in filling in Simon's package (or vice versa)
e.g. for the conversion of different data types,  some
reflectance material, etc.
I imagine Simon's package is a very good start, and I am
not offering this one as a competitor but hopefully
to encourage others to help merge the facilities.
I am happy to help make it do more things,
so if there are any issues, please mail me.

If I recall correctly,  there was an issue
with ObjectiveC on Linux and OSX handling references to structs
(or something "primitive") slightly different.
But I may just be forgetting.


Simon Urbanek wrote:
> I have put together a small and crude package that allows you to send 
> messages to Obj-C objects and classes and create references to objects, 
> classes and selectors. For historical reasons it's called Cocoa 
> (although Obj-C is strictly speaking not Cocoa) and you can get it from 
> my nightly builds page ( http://www.rosuda.org/R/nightly/ ).
> It is interesting only for developers as it's only the first step in a 
> complete Obj-C/R suite, but since some people seemed to be interested 
> in this, I thought I share it here. Some (admittedly stupid) examples:
> # Class sc = [NSString class]
> > sc<-.MCall("NSString","class")
> > sc
> Obj-C class: NSString
> # NSString *s = [NSString stringWithString:@"hello"]
> > s <- .MCall("NSString","stringWithString:","hello")
> > s
> hello
> # [s stringByAppendingString: @" World!")
> > s2 <- .MCall(s, "stringByAppendingString:", " World!")
> > s2
> hello World!
> # [s respondsToSelector: @selector(length)]
> > .MCall(s, "respondsToSelector:", .MSelector("length"))
> [1] TRUE
> (the M is front of the calls was motivated by the .m extension of Obj-C 
> code)
> and if you use Cocoa inside R.app you can do many stupid things like:
> c<-.MCall("RController", "getRController")
> .MCall(c, "toggleHistory:", c)
> Currently only boolean, id and Class results are supported and only 
> strings are automatically converted to NSString as arguments. Main work 
> to be done now is the support for scalar types, especially Cocoa-native 
> types like NSRange and so on. Anyone interested in this is welcome to 
> enhance the code ... Comments are very welcome, too. But again, this is 
> just a draft - no documentation, no guarantees ;).
> Cheers,
> Simon
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Duncan Temple Lang                duncan at wald.ucdavis.edu
Department of Statistics          work:  (530) 752-4782
371 Kerr Hall                     fax:   (530) 752-7099
One Shields Ave.
University of California at Davis
Davis, CA 95616, USA

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 184 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20041102/619f7a21/attachment.bin

More information about the R-SIG-Mac mailing list