[Openmcl-devel] Uncle!

Gary Byers gb at clozure.com
Fri Nov 2 16:32:59 PDT 2007

"unrecognized selector ... sent to ..." means almost exactly the same
thing as no-applicable-method would mean in CLOS: NSWindows don't
define a method on #'#/addSubview:  Right now, we're happy enough
to just catch the ObjC runtime exception (and happy that ObjC raises
an exception for this rather than just crashing like its C cousins
would), but it might be possible to report that error in a way
that doesn't use terms like "selector" and "send/sent".

The idiomatic way of setting up a window's view hierarchy is by
obtaining the window's content view (#/contentView window) and
then adding subviews to that.  A simple example of this is available


and there's a more aesthetically-pleasing but slightly more complicated
example at:


On Fri, 2 Nov 2007, Ron Garret wrote:

> Poking through the easygui code I encountered this intriguing tidbit:
> (defclass cocoa-drawing-view (ns:ns-view)
> ...
> (define-useful-mouse-event-handling-routines cocoa-drawing-view)
> Gotta love a language where you can define something called "define-
> useful-mouse-event-handling-routines"!
> So I decided to see what a cocoa-drawing-view did.  I tried this:
> (add-subviews (make-instance 'window) (make-instance 'cocoa-drawing-
> view))
> which doesn't work because cocoa-drawing-views are ns:ns-views, not
> views.  Ten minutes of head-scratching and reverse-engineering later I
> came up with this:
> (setf w (make-instance 'window))
> (setf d (make-instance 'cocoa-drawing-view))
> (dcc (#/addSubview: (cocoa-ref w) d))
> which produced:
> Calling addSubview: on (#<NS-WINDOW <NSWindow: 0xc4cd8f0> (#xC4CD8F0)>
> #<COCOA-DRAWING-VIEW <CocoaDrawingView: 0xc409d10> (#xC409D10)>)
> > Error: Objective-C runtime exception:
> >        *** -[NSWindow addSubview:]: unrecognized selector sent to
> instance 0xc4cd8f0
> > While executing: #<Anonymous Function #x3000411F1AAF>, in process
> Listener(54).
> > Type :POP to abort, :R for a list of available restarts.
> > Type :? for other options.
> at which point I decided it was time to ask for help.  Accordingly...
> Help!
> :-)
> Thanks,
> rg
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel

More information about the Openmcl-devel mailing list