[MacRuby-devel] How do I subclass Obj-C classes in MacRuby?
Terry Moore
tvmoore at mac.com
Thu May 6 21:54:52 PDT 2010
This is only true if you follow objc init I think... for example...
I came across this problem with NSWindowController and it took me a while to figure out.
class PasswordController < NSWindowController
def initialize
initWithWindowNibName("Password") ##FAIL Never called! init called instead
end
class PrefController < NSWindowController
def initialize(owner)
@owner = owner
initWithWindowNibName("Preferences")
end
end
The first example fails and so I finally got that I needed the init method to make the window appear but I couldn't figure out why the second option worked.
Must have been a long day but clearly if designate an initialize with a param init is bypased...
so if I take the
class A <String
def initialize(b)
super
end
end
example and do A.new("hi there") gives
initialize
=> "hi there"
so what is going on? I think there might need to be some clarity.....
Terry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20100507/587c5bde/attachment-0001.html>
More information about the MacRuby-devel
mailing list