Skip to content

Instantly share code, notes, and snippets.

@rob-murray
Created February 1, 2013 13:27
Show Gist options
  • Save rob-murray/4691299 to your computer and use it in GitHub Desktop.
Save rob-murray/4691299 to your computer and use it in GitHub Desktop.
An example of Objective C Global constant - shows class definition, implementation, import and usage
//Configuration.h
#import <Foundation/Foundation.h>
@interface Configuration : NSObject
extern NSString *const kRMAWebServiceURL;
extern const NSTimeInterval kRMTimeoutValue;
@end
//Configuration.m
#import "Configuration.h"
@implementation Configuration
NSString *const kRMAWebServiceURL = @"http://mywebservice.com";
const NSTimeInterval kRMTimeoutValue = 90;
@end
// AppName-Prefix.pch
// ... //
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "Configuration.h"
#endif
// ... //
/*
* Usage
*/
// Afile.m
- (void)aMethodThatDoesSomething
{
NSLog(@"%@", kRMAWebServiceURL);
NSLog(@"%f", kRMTimeoutValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment