Hi Łukasz, Since the bark method is defined in Ruby, it means its return value and arguments are objects (id). So, if you want to call the method from Objective-C, you must pass an Objective-C object. In this case, an NSNumber object should do it.
If the bark method was actually an Objective-C method overwritten in Ruby, then passing the C integer would have worked. Also, it is generally safer to use the -[performRubySelector:] method when calling specialized Ruby methods (those with optional or splat arguments). The Ruby method calling semantics differ a little bit from Objective-C so it won't always work. HTH, Laurent 2009/5/21 Łukasz Adamczak <[email protected]>: > My question boils down to a simpler case: > > Ruby: > -------- > class Dog > def bark(num = 1) > num.times { puts "woof!" } > end > end > > Objective-C: > ---------------- > id dog = [[MacRuby sharedRuntime] evaluateString:@"Dog.new"]; > [dog bark:3]; > > > Passing Objective-C int to a Ruby method crashes it. > > Assuming I don't have access to the Objective-C side (the caller) - > how do I make it work? > > Thanks! > > > -- > Regards, > Łukasz Adamczak > _______________________________________________ > MacRuby-devel mailing list > [email protected] > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > _______________________________________________ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
