Advertisement

Defining Constants Across an App

To simplify administration of an app, it makes sense to define a class, say AppConfig that details constants used throughout the app. Constants like the master url, particular geometries. Here’s the snippet:

 

.h file:

//

//  AppConfig.h

//  

//

//  Created by Peter Brockmann on 10/7/14.

//

//

#import <UIKit/UIKit.h>

#ifndef _0_AppConfig_h

#define _0_AppConfig_h

#endif

static const double KMASTER_WIDTH_MAX = 110.0f;

static const double  KMASTER_WIDTH_MIN = 109.0f;

FOUNDATION_EXPORTNSString *const KPIURL;

FOUNDATION_EXPORTNSString *const KISIURL;

FOUNDATION_EXPORT NSString *const KMASTERAPPROVALCODE;

 

 

and the .m file:

 

//

//  AppConfig.m

//  10

//

//  Created by Peter Brockmann on 10/17/14.

//

#import “AppConfig.h”

 

 

#define IOS_7_OR_EARLIER    ([[[UIDevice currentDevice] systemVersion] floatValue] <= 7.9)

 

 

NSString *const KISIURL = @”http://www.g.com/a.pdf;

 

NSString *const KMASTERAPPROVALCODE = @”ABC123\n10/2014″;