Using this line of code is not recommended.
@property (nonatomic, retain) AppDelegate *app;
in every classroom you need. An easy way to access the delegate application where you need it is this:
AppDelegate* appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
obviously you need to do:
#import "AppDelegate.h"
in the class in which you use it.
If you need a cleaner way to do this, you can create a class method in AppDelegate.h as follows:
+(AppDelegate*)sharedAppdelegate;
in AppDelegate.m is defined as follows:
+(AppDelegate*)sharedAppdelegate { return (AppDelegate*)[[UIApplication sharedApplication] delegate]; }
Then, where you need it, you can just call (after importing AppDelegate.h):
AppDelegate* sharedApp = [AppDelegate sharedAppdelegate];
Hope this helps.
PS Why do you need access to a delegate?
source share