Put all your variables inside a class, access the class via singleton pattern, and import the class header into the prefix.pch file
example :
GlobalClass.h
#import <Foundation/Foundation.h>
@interface GlobalClass : NSObject
@property (nonatomic, strong) NSString *globalString;
@property (nonatomic, strong) NSNumber *globalNumber;
+ (GlobalClass*) sharedClass;
- (void) methodA;
@end
and in GlobalClass.m
#import "GlobalClass.h"
@implementation GlobalClass
+ (GlobalClass *)sharedClass {
static GlobalClass *_sharedClass = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedClass = [[GlobalClass alloc] init];
});
return _sharedClass;
}
- (id)init {
self = [super init];
if (self) {
//init variable here
}
return self;
}
- (void) methodA {
//do something here
NSLog(@"this is methodA called");
}
@end
put this inside your .pch file in supporting files
#import "GlobalClass.h"
now you can access the global class variable from any class, by using :
[GlobalClass sharedClass].globalString = @"this is a global string";
you can also access the method, by using :
[GlobalClass sharedClass] methodA];