On 2014-11-18 09:07:10 +0000, Christian Schneider said:

This is what I came up with so far:

override KeyboardView initWithFrame(NSRect frame) [initWithFrame:] {
     //my stuff
     return cast(KeyboardView) super.initWithFrame(frame) ;
}

Why not use a constructor and let the compiler manage the boilerplate?

        this(NSRect frame) [initWithFrame:] {
                //my stuff
                super(frame);
        }

This should emit the same code as the function above (but I haven't tested). And then you can write:

        auto view = new KeyboardView(someFrame);

and have proper type safety.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

              • R... Jacob Carlborg via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
              • R... Jacob Carlborg via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
              • R... Jacob Carlborg via Digitalmars-d-announce
              • R... Jacob Carlborg via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
              • R... Jacob Carlborg via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
              • R... Michel Fortin via Digitalmars-d-announce
              • R... Christian Schneider via Digitalmars-d-announce
            • Re: D... Michel Fortin via Digitalmars-d-announce
              • R... Jacob Carlborg via Digitalmars-d-announce
  • Re: D/Objective-C 64bit Martin Nowak via Digitalmars-d-announce

Reply via email to