新建一个类 UBConst.h
.h
@interface UBConst : NSObject
extern NSString *const HTTP_URL;
extern const int DEFAULT_PORT;
@end
.m
#import "UBConst.h"
@implementation UBConst
const int DEFAULT_PORT = 80;
NSString * const HTTP_URL = @"http://www.kjson.com/jsonparser/";
@end
3.ViewController.h中使用
#import "ViewController.h"
#import "UBConst.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
NSString *string = [NSString stringWithFormat:@"我是%@",HTTP_URL];
NSLog(@"222222====%@ and ==== %d",string,DEFAULT_PORT);
}