Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Cross refering header problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cross refering header problem



Thanks Ricci and Nathan for your replies, it helped! All this header file
business seems quite redundant from a Java point of view, but with your
comments I can survive it.

Ricci wrote:

> Whenever I have to do this, I use #import in one header file and @class
> in the other.  This usually does not result in errors for me.  Can you
> specify on what errors you are getting?

Using only @class solves the compiler error, but the warnings [class ...
does not respond to message ...] remain, although they are shown only once
for every clean target. Nathans solution solves this.

> Instead of having each class know about the other, I will normally have
> the connection go only one way.  If the "slave" class needs to tell the
> "master" class something, I will either use NSNotifications or have the
> master class repetitively check.  This is my personal style though, and
> probably quite a few people do it differently :)

I have not looked into NSNotifications, but I will. I guess some of these
situations can indeed be solved by using the right design pattern.

Nathan wrote:

> If you use @class, which you should if all you need to known about is
> the existence of a class, then you still need to import the header file
> into any implementation file that makes use of that class. So in the
> header you might have
>
> @class    MyClassA, MyClassB, MyClassC;
>
> and then in the implementation file you have
>
> #import "MyClassA.h";
> #import "MyClassB.h";
> #import "MyClassC.h";

This does exactly what I want: all interface information available and no
compiler errors or warnings. This seems to be the trick!

Groeten,

Patrick
_______________________________________________
studentdev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/studentdev
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.