Usually I add one file called Constant.h
in my project and import it in my project's -Prefix.pch file so that I can access content in any file.
The drawback is when I modify the Constant.h
file I need to compile the whole project file. A long time if your machine is not so fast.
Example:
#ifndef BadgeDiscount_Constant_h
#define BadgeDiscount_Constant_h
typedef enum {
kErrorCodeTokenExpired = 61001,
kErrorCodeServerInternalError = 500,
kErrorCodeRequestTimeout = -1001,
kErrorCodeCouldNotAccessServer = -1004,
kErrorCodeInternetUnavailable = -1009,
} ErrorCode;
typedef enum {
kRowTypeTopAndAlsoBottom = 1,
kRowTypeTop,
kRowTypeMiddle,
kRowTypeBottom
} RowType;
extern CGFloat kScreenWidth;
extern CGFloat kScreenHeight;
static CGFloat const kStatusBarHeight = 20;
static CGFloat const kNavigationBarHeight = 44;
static NSString* const kErrorMessage = @"errMsg";
static NSString* const kErrorCode = @"errCode";
#endif
And the -Prefix.pch file:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "Constant.h"
#import "AppDelegate.h"
#import "MBProgressHUD.h"
#endif