From: Jonathan P. <jp...@dc...> - 2005-11-04 21:05:18
|
On 4 Nov 2005, at 20:53, Rupert BARROW wrote: > > kvc_accessor :lastName, :firstName, :employeeID > kvc_depends_on > ([ :lastName, :firstName, :employeeID ], :fullNameAndID) > > def initialize > rbSetValue_forKey(NSNumber.numberWithInt(@@lastID), > "employeeID") > > I am setting the employeeID correctly (through setValue), but the > value is not 'arriving' in the coredata object. However, it is not > lost, because I re-read from in another method (fullNameAndID) with > the valueForKey method. You're calling rbSetValue... rather than setValue... The rbSetValue method ends up just calling the ruby employeeID= method, which has the effect of setting the instance variable in the ruby class (look at the definition in oc_import.rb to understand more). Try replacing kvc_accessor with kvc_wrapper, as defined by Kimura Wataru in an email earlier today in this thread. This declares the ruby-level accessors in terms of setValue:forKey: and valueForKey: which should hopefully solve the problem. i.e.: kvc_wrapper :lastName, :firstName, :employeeID kvc_depends_on ([ :lastName, :firstName, :employeeID ], :fullNameAndID) def initialize employeeID = @@lastID ... end Also, since this is a Cocoa class, I'm not sure that the initialize method works - I think you have to override init and define it like in a Cocoa class. I'll try and come up with an example later if you think this is a problem. Hope that helps. Jonathan |