From: Aron N. <aro...@gm...> - 2008-05-13 09:50:36
|
Hi All, I'm trying to implement property validation methods (validate<Name>:error:, or, rather, validate<Name>_error in Ruby) in a Ruby class. I am able to call the validation methods directly from objc, but they are not called when running "validateValue:forKey:error:". Turning on RubyCocoa logging shows no activity on the bridge when validateValue:forKey:error: is called. I replicated the issue using a simple example. Am I missing something obvious here? I'm using the Ruby and RubyCocoa shipped with Leopard. Thanks from a newbie, Aron Sample Ruby code: require 'OSX/Cocoa' include OSX class A < NSObject kvc_accessor :prop def validateProp_error(value, error) puts "In validation" return true; end end Sample objc code: #import <Cocoa/Cocoa.h> #import <RubyCocoa/RBRuntime.h> #import <stdio.h> int main(int argc, const char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int stat = RBApplicationInit("validate.rb", argc, argv, nil); if (stat != 0) { fprintf(stderr, "Error in ruby initialization\n"); [pool release]; return stat; } Class rubyClass = NSClassFromString(@"A"); NSObject *obj = [[rubyClass alloc] init]; // The following doesn't work: [obj validateValue: nil forKey: @"prop" error: nil]; // The following does work: // [obj validateProp: nil error: nil]; [pool release]; } |