Last Updated: February 25, 2016
· sendoa

Elegant global access to App Delegate

I know, I know… accessing the app delegate globally is not always a good idea but sometimes it's just the right thing to do. This is an easy and elegant way to access it from any file in our project:


#import <UIKit/UIKit.h>

#define ApplicationDelegate ((MyAppDelegate *)[UIApplication sharedApplication].delegate)

@interface MyAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (copy, nonatomic) NSString* aString;


Any other file on the project

NSString* myString = ApplicationDelegate.aString;