Possible Duplicate:
What is the difference between #import and #include in Objective-C?
What is the difference between
#include< >
#include" "
#import< >
#import" "
Possible Duplicate:
What is the difference between #import and #include in Objective-C?
What is the difference between
#include< >
#include" "
#import< >
#import" "
The #import
directive is an improved version of #include
.
#import
ensures that a file is only ever included once so that you never have a problem with recursive includes.
#import ""
first check the header in project folder then goes to system library, and the #import<>
checks for system headers". In theory the locations are compiler defined and they could be implemented differently on a given platform.
When using #import
, the header include guard is unnecessary. Otherwise, it's just like #include
.
The header include guard, seen in C and C++ files:
#ifndef HGUARD_MONHeader_h
#define HGUARD_MONHeader_h
...header contents...
#endif
import is super set of include, it make sure file is included only once. this save you from recursive inclusion. about "" and <>. "" search in local directory and <> is use for system files.
The #import directive was added to Objective-C as an improved version of #include. Whether or not it's improved, however, is still a matter of debate. #import ensures that a file is only ever included once so that you never have a problem with recursive includes. However, most decent header files protect themselves against this anyway, so it's not really that much of a benefit.
What is the difference between #import and #include in Objective-C? :
#include and #import request that the preprocessor* read a file and add it to its output. The difference between #include and #import is that
#include allow you to include the same file many times. #import ensures that the preprocessor only includes a file once. C programmers tend to use #include. Objective-C programmers tend to use #import.
* Compiling a file in Objective-C is done in two passes. First,
the preprocessor runs through the file. The output from the preprocessor goes into the real compiler.