Last Updated: December 26, 2018
·
4.621K
· sergigracia

Share your App Delegate as project constant

Define your AppDelegate as project constant in your Project-Prefix.pch file:

#ifdef __OBJC__
    //...
    #import "YourAppDelegate.h"
    #define SharedAppDelegate ((YourAppDelegate *)[[UIApplication sharedApplication] delegate])
#endif

And now you can access to your AppDelegate methods from any project file this way:

[SharedAppDelegate myMethod];