Ask a Question related to Mac Programming, Design and Development.
-
C Lund #1
Warning: 'Class' does not respond to 'method'
I have three classes: Map, which accumulates NSMutableArrays of the
other two classes, Surface and Vertex. Communication between Map and
the other two classes works fine. But Surface and Vertex needs to keep
pointers to instances of each other. The pertinent part of the header
files (afaik) are:
------------------
Map.h:
#include "Surface.h"
#include "Vertex.h"
@interface Map : NSObject
{
NSMutableArray *surfaceList;
NSMutableArray *vertexList;
}
@end
------------------
Surface.h:
@class Vertex;
@interface Surface : NSObject
{
Vertex *vertexList[3];
Surface *surfaceList[3];
}
@end
------------------
Vertex.h:
@class Surface;
@interface Vertex : NSObject
{
GLfloat vertexCoord[3];
NSMutableArray *surfaceList;
}
-(GLfloat)coord:(int)index; //returns vertexCoord[index]
@end
------------------
If I try to call [vertexList[0] coord:0] from an instance of Surface,
PB gives me a 'Vertex' does not respond to 'coord:'.
What am I doing wrong here?
--
C Lund, [url]www.notam02.no/~clund[/url]
C Lund Guest
-
XML::Writer method 'pi' returns confusing warning message
I'm getting the following warning message: "Processing instruction target begins with 'xml' at .../makeconf/LW/LWTest.pm line 75" The pi()... -
#25580 [WFx]: set_error_handler to a class/method resets class properties when error occurs
ID: 25580 Updated by: sniper@php.net Reported By: paul dot liversidge at recycledpixels dot com Status: Wont... -
#25580 [Opn->WFx]: set_error_handler to a class/method resets class properties when error occurs
ID: 25580 Updated by: sniper@php.net Reported By: paul dot liversidge at recycledpixels dot com -Status: Open... -
#25580 [Opn]: set_error_handler to a class/method resets class properties when error occurs
ID: 25580 User updated by: paul.liversidge@recycledpixels.com Reported By: paul dot liversidge at recycledpixels dot com... -
#25580 [NEW]: set_error_handler to a class/method resets class properties when error occurs
From: paul dot liversidge at recycledpixels dot com Operating system: Windows XP PHP version: 4.3.2 PHP Bug Type: ... -
matt neuburg #2
Re: Warning: 'Class' does not respond to 'method'
In <clund-D1DC50.14051623082003@amstwist00.chello.com> C Lund wrote:
You probably didn't #import Vertex.h into the file where you're making> If I try to call [vertexList[0] coord:0] from an instance of Surface,
> PB gives me a 'Vertex' does not respond to 'coord:'.
> What am I doing wrong here?
this call. m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
REALbasic: The Definitive Guide! 2nd edition!
[url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
Subscribe to TidBITS. It's free and smart.
matt neuburg Guest
-
C Lund #3
Re: Warning: 'Class' does not respond to 'method'
In article <20030823081318400-0700@news.la.sbcglobal.net>,
matt neuburg <matt@tidbits.com> wrote:
No, I didn't. The problem is that I will also be calling Surface> In <clund-D1DC50.14051623082003@amstwist00.chello.com> C Lund wrote:>> > If I try to call [vertexList[0] coord:0] from an instance of Surface,
> > PB gives me a 'Vertex' does not respond to 'coord:'.
> > What am I doing wrong here?
> You probably didn't #import Vertex.h into the file where you're making
> this call. m.
methods from Vertex, and if I import both class headers into each
other (I've tried this) I get a bunch of errors involving previous
declarations, conflicting types, duplicate interface declaration
warnings, and so on. Both classes need to be able to call each other's
accessor methods.
--
C Lund, [url]www.notam02.no/~clund[/url]
C Lund Guest
-
C Lund #4
Re: Warning: 'Class' does not respond to 'method'
In article <clund-6121D9.18230423082003@amstwist00.chello.com>,
C Lund <clund@NOSPAMnotam02.no> wrote:Well, I'll #import Vertex.h in Surface for now. That works for now> In article <20030823081318400-0700@news.la.sbcglobal.net>,
> matt neuburg <matt@tidbits.com> wrote:> No, I didn't. The problem is that I will also be calling Surface> > You probably didn't #import Vertex.h into the file where you're making
> > this call. m.
> methods from Vertex, and if I import both class headers into each
> other (I've tried this) I get a bunch of errors involving previous
> declarations, conflicting types, duplicate interface declaration
> warnings, and so on. Both classes need to be able to call each other's
> accessor methods.
anyway. Maybe I can avoid calling Surface methods from Vertex.
--
C Lund, [url]www.notam02.no/~clund[/url]
C Lund Guest
-
Michael Ash #5
Re: Warning: 'Class' does not respond to 'method'
In article <clund-6121D9.18230423082003@amstwist00.chello.com>,
C Lund <clund@NOSPAMnotam02.no> wrote:
Here's the proper way to do this in ObjC.> In article <20030823081318400-0700@news.la.sbcglobal.net>,
> matt neuburg <matt@tidbits.com> wrote:
>>> > In <clund-D1DC50.14051623082003@amstwist00.chello.com> C Lund wrote:> >> > > If I try to call [vertexList[0] coord:0] from an instance of Surface,
> > > PB gives me a 'Vertex' does not respond to 'coord:'.
> > > What am I doing wrong here?
> > You probably didn't #import Vertex.h into the file where you're making
> > this call. m.
> No, I didn't. The problem is that I will also be calling Surface
> methods from Vertex, and if I import both class headers into each
> other (I've tried this) I get a bunch of errors involving previous
> declarations, conflicting types, duplicate interface declaration
> warnings, and so on. Both classes need to be able to call each other's
> accessor methods.
If you need to inherit from a class, #import it in your .h file.
If you need to reference a class in a .h file but not inherit from it,
use @class Class.
If you need to send messages to objects of a class where you just did
@class Class in your .m file, also #import it in your .m file.
This last one is important. It's how you avoid circular #imports and
everybody goes home happy.
Michael Ash Guest
-
Tom Harrington #6
Re: Warning: 'Class' does not respond to 'method'
In article <clund-6121D9.18230423082003@amstwist00.chello.com>,
C Lund <clund@NOSPAMnotam02.no> wrote:
I'd guess this problem arises from the fact that your Map.h snippet> In article <20030823081318400-0700@news.la.sbcglobal.net>,
> matt neuburg <matt@tidbits.com> wrote:
>>> > In <clund-D1DC50.14051623082003@amstwist00.chello.com> C Lund wrote:> >> > > If I try to call [vertexList[0] coord:0] from an instance of Surface,
> > > PB gives me a 'Vertex' does not respond to 'coord:'.
> > > What am I doing wrong here?
> > You probably didn't #import Vertex.h into the file where you're making
> > this call. m.
> No, I didn't. The problem is that I will also be calling Surface
> methods from Vertex, and if I import both class headers into each
> other (I've tried this) I get a bunch of errors involving previous
> declarations, conflicting types, duplicate interface declaration
> warnings, and so on. Both classes need to be able to call each other's
> accessor methods.
shows you including both Surface.h and Vertex.h. Any reason not to
change those into @class declarations? Does Map.h really need to know
the full interface of Vertex and Surface, or is it enough for it to just
know that they exist?
--
Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 1.4: Best cleanup yet, gets files other tools miss.
See [url]http://www.atomicbird.com/[/url]
Tom Harrington Guest
-
C Lund #7
Re: Warning: 'Class' does not respond to 'method'
In article <mail-1A9964.12161223082003@localhost>,
Michael Ash <mail@mikeash.com> wrote:
You mean @class Class in the *header* file, right? Because that way it> Here's the proper way to do this in ObjC.
>
> If you need to inherit from a class, #import it in your .h file.
>
> If you need to reference a class in a .h file but not inherit from it,
> use @class Class.
>
> If you need to send messages to objects of a class where you just did
> @class Class in your .m file, also #import it in your .m file.
works.
I am anyway. Thanks. B)> This last one is important. It's how you avoid circular #imports and
> everybody goes home happy.
--
C Lund, [url]www.notam02.no/~clund[/url]
C Lund Guest
-
Michael J Ash #8
Re: Warning: 'Class' does not respond to 'method'
On Sat, 23 Aug 2003, C Lund wrote:
Uh, yeah, that's what I meant. :P> You mean @class Class in the *header* file, right? Because that way it
> works.
Glad to hear it.>> > This last one is important. It's how you avoid circular #imports and
> > everybody goes home happy.
> I am anyway. Thanks. B)
--
"From now on, we live in a world where man has walked on the moon.
And it's not a miracle, we just decided to go." -- Jim Lovell
Mike Ash - <http://www.mikeash.com/>, <mailto:mail@mikeash.com>
Michael J Ash Guest
-
Mark Haase #9
Re: Warning: 'Class' does not respond to 'method'
In article <clund-AF03E0.18383223082003@amstwist00.chello.com>,
C Lund <clund@NOSPAMnotam02.no> wrote:
I think this is generally the best way to approach the problem. A clean> Well, I'll #import Vertex.h in Surface for now. That works for now
> anyway. Maybe I can avoid calling Surface methods from Vertex.
top-to-bottom class hierarchy ought (IMO, or at least in my experience)
not to need backwards references.
Ie. The car class knows the interface of the engine class, but not vice
versa.
If you mess up and find yourself need to reference an object that you
can't #include, then a quick hack is to just use an id. Luckily in Obj-C
you can send messages to objects even if they don't repond to that type
of message.
Mark Haase Guest
-
matt neuburg #10
Re: Warning: 'Class' does not respond to 'method'
In <mehaase-FEA559.10441824082003@netnews.upenn.edu> Mark Haase wrote:
You're missing the point. The whole point of #import (as opposed to #> In article <clund-AF03E0.18383223082003@amstwist00.chello.com>,
> C Lund <clund@NOSPAMnotam02.no> wrote:
>>>> Well, I'll #import Vertex.h in Surface for now. That works for now
>> anyway. Maybe I can avoid calling Surface methods from Vertex.
> I think this is generally the best way to approach the problem. A
> clean top-to-bottom class hierarchy ought (IMO, or at least in my
> experience) not to need backwards references.
include) is that circularity is prevented for you automagically. m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
REALbasic: The Definitive Guide! 2nd edition!
[url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
Subscribe to TidBITS. It's free and smart.
matt neuburg Guest
-
Michael Ash #11
Re: Warning: 'Class' does not respond to 'method'
In article <20030824084300575-0700@news.la.sbcglobal.net>,
matt neuburg <matt@tidbits.com> wrote:
No, that's exactly not it at all.> In <mehaase-FEA559.10441824082003@netnews.upenn.edu> Mark Haase wrote:>> > In article <clund-AF03E0.18383223082003@amstwist00.chello.com>,
> > C Lund <clund@NOSPAMnotam02.no> wrote:
> >> >> >> Well, I'll #import Vertex.h in Surface for now. That works for now
> >> anyway. Maybe I can avoid calling Surface methods from Vertex.
> > I think this is generally the best way to approach the problem. A
> > clean top-to-bottom class hierarchy ought (IMO, or at least in my
> > experience) not to need backwards references.
> You're missing the point. The whole point of #import (as opposed to #
> include) is that circularity is prevented for you automagically. m.
#import prevents double-includes, where you get a file twice and you get
a million errors because everything's declared again. #import most
definitely does not prevent circularity. All it does is check to see if
you've already #imported the file and, if you have, doesn't do it again.
But this will cause problems if you have circular #imports. If A.h
#imports B.h and B.h #imports A.h, things won't work. A.h #imports B.h,
ok, then B.h #imports A.h which will have no effect because A.h is
already there. But B.h needs A.h to function, so you get errors.
As I said, the way to handle this is to only #import things in your .h
files when absolutely necessary (when you're inheriting). Otherwise use
@class declarations in the .h file and #import in the .m file. This
avoids circularity and works properly in every case.
Michael Ash Guest
-
matt neuburg #12
Re: Warning: 'Class' does not respond to 'method'
In <mail-E5F865.10562324082003@localhost> Michael Ash wrote:
Really? Well, then, maybe *I've* been missing the point! :) I thought> In article <20030824084300575-0700@news.la.sbcglobal.net>,
> matt neuburg <matt@tidbits.com> wrote:
>>>> In <mehaase-FEA559.10441824082003@netnews.upenn.edu> Mark Haase
>> wrote:>>>> > In article <clund-AF03E0.18383223082003@amstwist00.chello.com>,
>> > C Lund <clund@NOSPAMnotam02.no> wrote:
>> >
>> >> Well, I'll #import Vertex.h in Surface for now. That works for now
>> >> anyway. Maybe I can avoid calling Surface methods from Vertex.
>> >
>> > I think this is generally the best way to approach the problem. A
>> > clean top-to-bottom class hierarchy ought (IMO, or at least in my
>> > experience) not to need backwards references.
>> You're missing the point. The whole point of #import (as opposed to #
>> include) is that circularity is prevented for you automagically. m.
> No, that's exactly not it at all.
>
> #import prevents double-includes, where you get a file twice and you
> get a million errors because everything's declared again. #import
> most definitely does not prevent circularity.
the whole idea was that every .m file could just #include every .h file
without fear. It has always worked for me. (I never #import an .h file
in an .h file, though, unless it's the superclass.) m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
REALbasic: The Definitive Guide! 2nd edition!
[url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
Subscribe to TidBITS. It's free and smart.
matt neuburg Guest
-
matt neuburg #13
Re: Warning: 'Class' does not respond to 'method'
In <mail-25C855.12384824082003@localhost> Michael Ash wrote:
Right, I see - if C is B's superclass that could happen easily. m.> Double-includes is something different from
> circularity, where A includes B and C, but B also includes C. This is
> what #import protects against.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
REALbasic: The Definitive Guide! 2nd edition!
[url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
Subscribe to TidBITS. It's free and smart.
matt neuburg Guest



Reply With Quote

