You can declare variables in .h
files.
globals.h:
extern int myGlob;
You cannot define the variable in a .h
, You have to define it in a .c
or .m
:
globals.m:
int myGlob;
You can import globals.h
from any other file that needs to access myGlob
:
myApp.m:
#import "globals.h"
main() {
myGlob++;
}