MacRuby is still unfinished - it just doesn't work with some of the ruby code I work with.
I've run into the same NSData problem, and I was able to create a CFData instance which appears ok with the following code
gem 'RubyInline'
require 'inline'
class CFDataWrapper
begin
inline do |builder|
builder.include "<CoreFoundation/CoreFoundation.h>"
builder.c_raw_singleton "
static VALUE fromString(int argc, VALUE *args){
CFDataRef d = CFDataCreate(NULL, RSTRING_PTR(args[0]), RSTRING_LEN(args[0]));
VALUE result;
char type = '@';
ocdata_to_rbobj(Qnil,&type, (const void *)&d, &result, false) ;
return result;
}
"
end
end
end
bytes = [128].pack('i1')
data = CFDataWrapper.fromString(bytes)
puts data.inspect
The output from inspect is different from under 10.6 but I can pass it back into methods that expect NSData instances and they appear to work, call NSData methods on it etc. Beyond this toy script it works a script i use to populate core data documents, where one of the entities has a binary data attribute