|
From: Judah J. <jud...@gm...> - 2008-04-06 19:28:43
|
On Sun, Apr 6, 2008 at 8:21 AM, Christopher St John <cks...@gm...> wrote:
> I see that the project has moved to Google code, but I didn't any
> mailing lists there, is this list still active? I'll give it a shot...
>
> I'm using HOC from the google code subversion repository on
> OS X 10.4.11 with ghc 6.8.2. I'm running through some exercises
> in the HIllegass Cocoa Programming book. I'm trying to create
> a custom view that has a designated initializer like this:
>
> - (id)initWithFrame:(NSRect)rect
> {
> if( self = [super initWithFrame:rect] ) {
> ...
> }
> return self;
> }
>
> I have the class ("StetchView") implemented in Haskell, and,
> with the exception of the initializer, it runs:
>
> $(declareClass "StretchView" "NSView")
>
> $(exportClass "StretchView" "sv_" [
> InstanceVariable "path" [t| Maybe (NSBezierPath ()) |]
> [| Nothing |],
> InstanceMethod 'drawRect,
> InstanceMethod 'initWithFrame,
> InstanceMethod 'windowNibName
> ])
>
> I've got the initializer looking like this (I was trying to cut
> it down to the absolute minimum):
>
> sv_initWithFrame rect self = do
> return self
>
> But that doesn't work, see below for what happens.
I think you need the following (untested, but I confirmed that it typechecks):
sv_initWithFrame rect self = do
initWithFrame rect (super self)
-- any other custom initialization code goes here
Note that this corresponds to the call to [super initWithFrame:rect]
in the Objective-C code you posted above.
Hope that helps,
-Judah
|