#import vs. @class

时间:2021-05-30 06:21:36

You #import or #include when there is a physical dependency. Otherwise, you use forward declarations (@class MONClassstruct MONStruct@protocol MONProtocol).

Here are some common examples of physical dependence:

  • Any C or C++ value (a pointer or reference is not a physical dependency). If you have a CGPoint as an ivar or property, the compiler will need to see the declaration of CGPoint.
  • Your superclass.
  • A method you use.

参考:http://*.com/questions/322597/class-vs-import