# Include is used in C/C ++ to include the header file. The disadvantage is that the same header file may be contained multiple times.
# Import is used in OC to include the header file. The advantage is that the same header file can only be contained once.
@ ClassAnd# ImportIt is to solve the deadlock problem caused by loop reference.
# Import will contain all information about this class, including entity variables and methods, while @ class only tells the compiler that the name declared after it is the name of the class, as for how this class is defined, you do not need to consider it for the moment. We will tell you later.
In the class declaration. generally, you only need to know the name of the referenced class in the H file, and do not need to know its internal entity variables and methods. in the H file, @ class is generally used to declare that this name is the name of the class. But in the implementation class. Because the internal object variables and methods of the referenced class are used, you need to use # import to include the header file of the referenced class.
If there is a circular dependency such as a-> B, B-> A, if # import is used to contain each other, a compilation error occurs, if @ class is used to declare each other in the header files of the two classes, no compilation error occurs.
So in general, @ class is placed in the. h file, just to reference this class in. h and reference this class as a type. In the. M file that implements this. h file, if you need to reference the object variables or methods of this class, use # import.