Tuesday, 18 August 2015

Store constants value in an iOS app

Constants.h

#define kFilterDate @"date"
#define kFilterRadius @"radius"
#define kFilterSort @"sort"

//Global Strings
#define kDividingString @" / "

//Strings
#define kTour @"Tour"

#define kToursKey @"tours"

Project_Prefix.pch

//
// Prefix header for all source files of the project
//

#ifdef __OBJC__
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
    #import "Constants.h"

#endif

(OR)

Define global constants:

Constants.h

extern NSString* const kAppBaseURL;

Constants.m

#import "Constants.h"

NSString* const kAppBaseURL = @"http://url.com/";



Project_Prefix.pch

//
// Prefix header for all source files of the project
//

#ifdef __OBJC__
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
    #import "Constants.h"

#endif

No comments:

Post a Comment