Hope this answers more clearly. In my case, I want to create a global class, but:
I DO NOT WANT:
[GlobalResource shareInstance].bgrMenuFileName;
I WANT:
R.bgrMenuFileName
Do something like that! In the GlobalResource.h file:
@class GlobalResource; extern GlobalResource * R; @interface GlobalResource: NSObject + (void) loadGlobalResources; @end
In the GlobalResource.m file:
// you must redeclare R GlobalResource *R; // then init it @implementation GlobalResouce + (void) loadGlobalResources { R = [[GlobalResource alloc] init]; } - (id)init { self = [super init]; if (self) { // your init } return self; } @end
Then call loadGlobalResources when your application loads:
[GlobalResource loadGlobalResources]
and import into Prefix.pch to use R anywhere in your project.
#import "GlobalResource.h"
Use it:
CCSprite *s = [CCSprite spriteWithFile:R.bgrMenuFileName];
source share