1. @ class
- Use Cases:For cyclic dependency, for example, Class A references Class B, and Class B also references Class;
We can see that the Person and Card references each other. If # import compilation is used, an error is returned! Therefore, when @ class is used to declare each other in two classes, no error will be reported during compilation!
- Usage:Use the @ class name to reference a class. It indicates that it is a class.
- # The import method contains all information about the referenced class, including the variables and methods of the referenced class. The @ class method only tells the compiler that. in the H file, B * B is only a class declaration. You do not need to know the specific information in this class. When the implementation file is actually used, to view information in Class B.
- If there are hundreds of header files # import the same file, or these files are # improt in turn, once the first header file is slightly changed, all the classes referenced in this file need to be re-compiled. This efficiency can be imagined. In contrast, this problem will not occur when @ class is used.
- In the. m implementation file, if you need to reference the object variables or methods of the referenced class, you also need to use the # import method to introduce the referenced class
2. Loop retain
- For example, if object A retests object B, object B retests object.
- In this way, object A and object B will never be released.
<Foundation/Foundation.h>* - ( <Foundation/Foundation.h> - ( <Foundation/Foundation.h> main( argc, **person =*card = person.card = card; card.person =