Remember that Objective-C is a strict superset of C, so you can declare global variables just like regular C. First, declare them in a file outside of any function, then use the C extern
keyword in other files to pull these variables.
If you want to do this with more than C variables, but rather use Objective-C objects, you can save them in the applicationโs deletion. Just set them there, as usual, when you need to access the variable:
It may also be useful for you to declare a static variable in the application delegate.
source share