-1

Possible Duplicate:
What is the difference between #import and #include in Objective-C?

It seems both can work when I use import or include in Objective-C, what's the difference between those two?

Community
  • 1
  • 1
user705414
  • 20,472
  • 39
  • 112
  • 155
  • 3
    this question has already been asked and answered here: http://stackoverflow.com/questions/439662/what-is-the-difference-between-import-and-include-in-objective-c – EdChum Apr 08 '12 at 15:27

1 Answers1

2

..#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 user #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. Preprocessor directives start with #. The three most popular are

-#include

-#import

-#define

iluvatar_GR
  • 1,017
  • 13
  • 19