Three ways to import files are compared:
@class, import, include in the preceding paragraph of the class:
1, the use of @class class name, it will tell the compiler has such a class, currently do not need to know its internal instance variable and method is how to define, will tell you, now you can directly use it, save the program compile time, 2, adopt import way, can avoid duplicate import the same class, It imports not only the contents of this class, but also before using it, the compiler must first go through all the contents of the class, that is, to do the pre-compilation process, so that the time spent compiling the program. 3, the use of include method, can not avoid the problem of repeated import, but it is used in the code writing in C + +, because #ifndef, #define, #endif这个是C/c++ language macro definition, macro definition to avoid multiple compilation of files. So it's all valid on all compilers that support C + + languages, and it's best to use this approach if you're writing programs that cross-platform . Description: When you write the OC code, if you declare a file in a class. h, when another class is required, the use of the preceding clause to declare the @class class name is the best choice because it omits the time for code compilation and improves efficiency, but in implementing the file. m file, you must use import Because the instance variables and methods of the class are used in the implementation file, the compiler must first pre-compile the contents of the class in advance.
Objective-c: Comparison of three ways to import files