Pierce T. Wetter III
pierc****@twinf*****
Wed Apr 11 14:25:27 JST 2007
So I'm trying to write a core data application with RubyCocoa. I'm having a weird problem in that its not calling my accessors. I'm guessing that this "warning" message is the problem: /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/ objc/oc_import.rb:502: warning: method redefined; discarding old dueDate Looking at the code, I'm guessing that something is going through and automatically redefining all my accessor methods to just use valueForKey and setValue_forKey and blowing away my definitions. How do I make it stop that? I think the problem stems from line 102 of cocoa_macros.rb. Sample code: (note that NONE of this code gets called, because of the method redefinition) FILE Machine_Action.rb: (This is generated via a mogenerator template) class Machine_Action < NSManagedObject #basic core data accessor methods def done willAccessValueForKey "done" result = primitiveValueForKey "done" didAccessValueForKey "done" result end def setDone(value_) print "msetDone" willChangeValueForKey "done" setPrimitiveValue_forKey(value_, "done") didChangeValueForKey "done" end def done=(value) print "mdone=" setDone(value) end def done? done != nil && done.intValue != 0 end end FILE: Action.rb require "Machine_Action.rb" class Action < Machine_Action #override done to mix in the values of any child actions def done super.done if children? then mx=self.valueForKeyPath("child****@min*****") mn=self.valueForKeyPath("child****@max*****") return -1 if (mn!=mx) mx end end end Note that NEITHER of the above done methods get called, because of the redefinition above. Pierce