I am making an app in which a view controller needs to dismiss a UIAlertView when the user presses the home button. Therefore I need to do this through the app delegate. This view controller’s class also needs the app delegate for many other things, so I have a #import in its header file. Up until now I have been using @class in the app delegate for something else, but now I need a #import so that I can call the appropriate method on the view controller. How do I avoid a #import loop? Is there another way of going about this?
Thanks.
Unless you actually need the full definition in the header, use
@classin the .h file, and#importin the .m file where you actually call the method.The only time you really need to use
#importin a header file is if the imported header defines your superclass.