Re: Syntax error when declaring an IBOutlet
Re: Syntax error when declaring an IBOutlet
- Subject: Re: Syntax error when declaring an IBOutlet
- From: Paul Goracke <email@hidden>
- Date: Thu, 6 Mar 2008 11:19:05 -0800
On Mar 6, 2008, at 10:16 AM, Mark Teagarden wrote:
I have another class, Display, that gives me the same error as the
one in
game.h - I've omitted it here for clarity. Basically, the mapview.h
#import
/ IBOutlet is the only one that worked correctly.
My questions are:
1. Why does identical code work in one file and not in the others?
It's not identical. It's also not "code"--it's a preprocessor
directive which is important because they have a tendency toward their
own "logic."
I'll bet your World.h includes '#import "Game.h"' which creates an
import cycle when imported from Game.h, but not when imported by
WMapView.h.
2. Why should @class work when #import doesn't? Hillegass flat out
says
that the two are interchangeable.
Where does he say that? I see the following in 2e Cocoa Programming:
You could replace '@class PreferenceController;' with '#import
"PreferenceController.h"'. This statement would import the header, and
the compiler would learn that PreferenceController was a class.
Because the 'import' command requires the compiler to parse more
files, '@class' will often result in faster builds.
which does _not_ call them interchangeable.
Ignoring the fact that @class is faster than #import (a nice benefit
in and of itself), it's a good rule of thumb to only use @class
declarations for your project headers and only actually #import
project headers from .m files, precisely to avoid these import cycles.
pg
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden