From: Laurent S. <lau...@gm...> - 2007-11-03 19:07:11
|
On Nov 3, 2007 1:18 PM, Rod Schmidt <rsc...@xm...> wrote: > I have the following Ruby code in my RubyCocoa app (in which I have > mostly Objective-C with some Ruby). > > class BackpackReminder > def CSS_class > date = NSDateToRubyDateTime(self.date) > now = DateTime.now > days_from_now = date.jd - now.jd > if days_from_now <= 30 then > "day#{days_from_now}" > else > "month#{self.months_from_now}" > end > end > end > > BackpackReminder is an Objective-C class, so I am reopening this class > and adding the CSS_Class method. This worked fine in Tiger. When I run > the app I get the following: > > 11/3/07 12:55:52 PM PackRat[1109] PageGenerator#generateHTML: > OSX::OCMessageSendException: Can't get Objective-C method signature > for selector 'CSS:class' of receiver > #<OSX::BackpackReminder_BackpackReminder_:0x265a5c > class='BackpackReminder' id=0x6115b0> > 11/3/07 12:55:52 PM PackRat[1109] Exception raised during posting of > notification. Ignored. exception: 'Can't get Objective-C method > signature for selector 'CSS:class' of receiver > #<OSX::BackpackReminder_BackpackReminder_:0x265a5c > class='BackpackReminder' id=0x6115b0>' invoked observer method: '*** - > [PackRatAppDelegate tableViewSelectionDidChange:]' observer: > 0x6f3dd0 notification name: 'NSTableViewSelectionDidChangeNotification' > > If I rename the method and remove the underscore and rename it > something like CSSClass, I get the same message (with the method name > changed of course). Has something changed in the Leopard version of > RubyCocoa that prevents you from reopening classes and adding methods? > No, nothing changed in this logic. However, most of the code that adds or overrides methods was ported to the ObjC 2.0 API, and maybe there is a regression in that area. I am nevertheless unable to reproduce this in a quick test. A few questions: 1/ Is the OSX module required? 2/ Does it also happen if you explicitly import the BackpackReminder class before doing the override? You can add ''OSX.ns_import : BackpackReminder'' at the beginning of the file to try that. 3/ Does the CSS_class method exists in the ObjC side? Thanks, Laurent |