Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!tank!nucsrl!gore From: gore@eecs.nwu.edu (Jacob Gore) Newsgroups: comp.sys.next Subject: Re: Debugging objects and connections Message-ID: <12670013@eecs.nwu.edu> Date: 2 Feb 89 04:49:37 GMT References: <4489@umd5.umd.edu> Organization: Northwestern U, Evanston IL, USA Lines: 45 / comp.sys.next / feldman@umd5.umd.edu (Mark Feldman) / Feb 1, 1989 / >I would >like to trap the fact that [bar setStringValue:myString] went off into space >or was not understood and have the chance to take corrective action. >Perhaps my corrective action would be nothing more than to put up a small >window explaining what had gone wrong in English. > >Ideas? I'm afraid I'm in no position to test this at the moment, and my Objective-C manual and knowledge are a couple of years old. But you did ask for ideas, so: Here's what that old manual says in the listing of methods for class Object (which every other class inherits from, directly or transitively): -doesNotRecognize:(STR)aMessage The message routine reports that the receiver did not recognize aMessage by sending 'doesNotRecognize:aMessage' to the receiver instead. It is defined as: return [self error:"%s does not recognize %s", NAMEOF(self), aMessage] In plain English, this means that what happens in your example is that '[bar doesNotRecognize:"setStringValue"]' is done, and 'bar' probably deals with it according to the "doesNotRecognize:" method it inherited from class Object (unless some class in between bar's class and class Object redeclared that method, in which case bar's class, of course, would inherit it from there). So, all you have to do is provide your own "doesNotRecognize:(STR)aMessage" method to 'bar', either in the definition of its class, or in the definition of one of its superclasses. If the current implementation of Objective-C supports multiple inheritance, the best way to handle this is to create a class, say, NotRecognizedPanel, which defines "doesNotRecognize:" to pop up one of those error panels with OK/Cancel/etc. choices. Then bar's class can just add NotRecognizedPanel to the list of its superclasses. Inheritance is fun. Jacob Gore Gore@EECS.NWU.Edu Northwestern Univ., EECS Dept. {oddjob,gargoyle,att}!nucsrl!gore