Hi Zach, On May 24, 2008, at 1:22 PM, Zach Holt wrote:
How would I turn this ObjC into MacRuby?
[ MyClass conformsToProtocol:@protocol( MyProtocol ) ];
Currently this is not possible (same in RubyCocoa), but with the enclosed patch: $ ./miniruby -e "framework 'Foundation'; p 'foo'.conformsToProtocol(Protocol.protocolWithName('NSObject'))" true $ ./miniruby -e "framework 'Foundation'; p 'foo'.conformsToProtocol(Protocol.protocolWithName('NSDoesNotExist'))" false Any idea regarding a shortcut? (Protocol.protocolWithName is too long). For example we could automatically convert symbols to Protocol objects. Also, calling #inspect on a Protocol object currently crashes (because it's not NSObject-based, where inspect is defined). Laurent Index: objc.m =================================================================== --- objc.m (revision 216) +++ objc.m (working copy) @@ -2914,3 +2914,13 @@ CFRunLoopAddTimer(CFRunLoopGetMain(), timer, kCFRunLoopDefaultMode); } } + +@interface Protocol +@end + +@implementation Protocol (MRFindProtocol) ++(id)protocolWithName:(NSString *)name +{ + return (id)objc_getProtocol([name UTF8String]); +} +@end