Re: [newbie] Cyclic #import
Re: [newbie] Cyclic #import
- Subject: Re: [newbie] Cyclic #import
- From: Sherm Pendley <email@hidden>
- Date: Wed, 8 Dec 2004 01:21:42 -0500
On Dec 8, 2004, at 12:46 AM, Christopher Drum wrote:
So, instead of...
#import <Cocoa/Cocoa.h>
#import "MyNetworker.h"
@interface MyController : NSObject
{
IBOutlet MyNetworker * networker;
}
you would write something like this...
#import <Cocoa/Cocoa.h>
@class MyNetworker;
@interface MyController : NSObject
{
IBOutlet MyNetworker *networker;
}
Now, the MyNetworker class is understood enough to reference your instance variable without getting into the cyclic nature of the multiple #imports. Plus, since you're not importing the full .h file, your builds should be a little faster (depending upon the length and complexity of such).
The major build-time improvement in the above comes from the elimination of unnecessary dependencies. Obviously, any time MyNetworker.h is touched, anything that directly imports it needs to be rebuilt. What's less obvious is that in the first example, anything that indirectly imports it by importing MyController.h would also need to be rebuilt.
The same idea applies to a suggestion earlier in this thread, where someone had the idea of importing all of your header files into one "master" header file, and including that "master" file in every .m file. That would *destroy* build times - any time *any* header file is touched, *every* .m file would need to be rebuilt as a result of the dependency bottleneck. That probably wouldn't be noticeable for trivial exercises - but for major applications it would be a major productivity drag.
With your improved example, there are no secondary dependencies to worry about. If you touch MyNetworker.h, only the .m files that directly import that header will need to be rebuilt. The .m files that import MyController.h without also importing MyNetworker.h won't be.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden