[MacRuby] #1388: Can't subclass NSProxy
MacRuby
ruby-noreply at macosforge.org
Wed Sep 14 17:56:07 PDT 2011
#1388: Can't subclass NSProxy
---------------------------+------------------------------------------------
Reporter: haxie1@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
---------------------------+------------------------------------------------
Comment(by mrada@…):
In normal Ruby, the Class class has a no-op implementation of the
inherited method so that the VM can always call the method on the
superclasses of a new class even if you do not provide an implementation
of your own. Since NSProxy does not live inside the standard inheritance
hierarchy, it implements the NSObject protocol instead of subclassing
NSObject, it does not get the methods that MacRuby has added to NSObject.
The missing methods are inherent in how Ruby is implemented, like
respond_to?.
I'm not sure of the actual solution to this problem, but it will only
happen for classes that do not inherit from NSObject. There are some
workarounds, like checking if the object responds to the selector first,
but the current system was designed to avoid that kind of overhead so I
don't think that that is a good solution. Another workaround might be to
define the class you are looking for in Objective-C, but you would also
have to define the other methods that MacRuby expects objects to have.
Someone else probably has better ideas, I am not too experienced with
Objective-C.
--
Ticket URL: <http://www.macruby.org/trac/ticket/1388#comment:2>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list