Last Updated: August 30, 2018
· 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])

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

[SharedAppDelegate myMethod];

1 Response
Add your response


Benefits of a constants file: All in one place, easy to find the file and localize

Benefits of constants in their relevant class files: modularity, easier to find in the file, follows OOP design principles (low coupling)https://www.applock.ooo/

Benefits of constants in appdelegate: None that I can see. It's messy, doesn't follow design principles, and it probably won't be any more efficient once compiled.https://www.minimilitia.mobi/

It's the compilers job to translate code structured for humans to code structured for CPUs. If you want to improve code efficiency, either find your bottlenecks or research common ones. (For example, using string interpolation over string concatenation will improve performance a lot more than sticking everything in one class)https://www.7zip.vip/
Edit; obviously since I don’t play often, I don’t want to spend too much- hence why I am looking at ps3.

about 2 months ago ·