1) No there is no a way you need to check if that import is used in your file (use find function for this);
2) The best way is import UNTIL IS POSSIBLE header in implementation file (.m
). If you need to declare that class in your header file (.h
) you can use:
@class nameClass
before begin with @interface
...etc.
If you already know that instead you need to import that class header file in your header, you can do it. Be careful to avoid #import
cycle. In fact suppose to have this situation:
MGCustomViewController.h:
#import "MGViewController.h"
@interface MGCustomViewController : UIViewController
@end
MGViewController.h:
#import "MGCustomViewController.h"
@interface MGViewController : MGCustomViewController
@end
This cause an error at compile time, because you inherit from MGCustomViewController
but importing MGCustomViewController.h
you are importing again this last header before that the compiler read the @interface MGCustomViewController
directive and so will show an error that says something like SUPERCLASS NOT FOUND.
3) No, but effects on the compile time.