You #import
or #include
when there is a physical dependency. Otherwise, you use forward declarations (@class MONClass
, struct 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 ofCGPoint
. - Your superclass.
- A method you use.
参考:http://*.com/questions/322597/class-vs-import