Welcome! Hope you enjoy your stay! You can write Obj-C-ish methods in MacRuby the same way you call them: using Ruby's hash syntax. The only other caveat is the difference between "super" in Ruby and Obj-C. In Obj-C, "super" is the superclass. In Ruby, it is shorthand for calling the same method in the superclass. Also, in Ruby, you are not allowed to redefine self. Finally, you generally don't need to worry about weak references in Ruby (since cycles can be handled by the GC). So your above method translated would look like this:
def initWithFrame(frame, controller: ctrlr) initWithFrame(frame) @controller = ctrlr self end Cheers, Josh On Wednesday, April 18, 2012 at 11:44 PM, Josh Voigts wrote: > Hey, first post to the list, woot! > > I've run into a little bit of a snag. Is there an elegant way of > building an initializer similar to this one in macruby? (assuming I'm > subclassing an NSView object) > > > - (id)initWithFrame:(NSRect)frame controller:(AppController *)ctrlr > { > if (self = [super initWithFrame:frame]) { > controller = ctrlr; // deliberately weak reference. > } > > return self; > } > _______________________________________________ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org (mailto:MacRuby-devel@lists.macosforge.org) > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > >
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel