|
|
Header import paradox
|
|
|
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
So I have a class which imports another class. The other class imports the first class. It's impossible to compile. How do you configure the compiler to accept that a class will exist, just a little down the line.
Here's the code in brief:
@interface SDMovieView : QTMovieView
{
SDVideoCell *cell;
}
@interface SDVideoCell : NSImageCell
{
SDMovieView *movieView;
}
Long story short, If I change the classes of the objects, it imports fine. If I change the order for the compiler, the error switches so that it's always in the first file, before the second one comes in. There is nothing wrong with the code. Just the compiler.
I don't understand why I can't have a Control know about it's cell and viceversa.
|
you are not your signature
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Sep 2003
Location: San Diego
Status:
Offline
|
|
This is a common problem in programming. You'll need to tell the compiler that you're going to define the second class later. In Obj-C you can use the "@class" specifer...
In you example, this should work:
@class SDVideoCell;
@interface SDMovieView : QTMovieView
{
SDVideoCell *cell;
}
@interface SDVideoCell : NSImageCell
{
SDMovieView *movieView;
}
Note: There are many times where having a circular dependancy like the above may be hinting at a bad design. I'm not sure if this is the case or not, but it's always wise to double check...
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Check out the @class declaration.
EDIT: Beaten to the punch by Smitty!
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
Thanks guys, and this when just for the first time I started poking around in the Cocoa header files and I was asking myself "Why the heck does NSCell's @class say:
@class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView;
and I guess that totally explains it.
...Yep: that fixes the problem!
|
you are not your signature
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|