Reputation: 29524
What are your opinions on #import
ing header files?
If I import:
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
and many more headers, and only use them once in a while, is it a waste? Does it slow down my app in any way? More importantly, does it increase the size of my app?
Thanks.
Upvotes: 0
Views: 109
Reputation: 8963
Adding to quixoto's answer, Objective-C added the
#import
Header. The original C header was:
#include
The difference is that #import actually checks to see if you have already included the header in your code. If you have, the #import statement does nothing.
Upvotes: 2
Reputation: 71008
Nope, it doesn't do any of those things.
Headers are used by the compiler to determine how to find where various types and classes are defined. Extraneous #imports do--kinda sorta--make the process of compiling your app slower by some unmeasurably small amount.
But the resulting binary application will not be any different in size or execution speed if you have redundant headers imported in your files.
Upvotes: 5