51 lines
1.3 KiB
Objective-C
51 lines
1.3 KiB
Objective-C
//
|
|
// DemoConfigLoader.m
|
|
// NewHttpDNSTestDemo
|
|
//
|
|
|
|
#import "DemoConfigLoader.h"
|
|
|
|
@implementation DemoConfigLoader {
|
|
NSString *_appId;
|
|
NSString *_primaryServiceHost;
|
|
NSInteger _servicePort;
|
|
NSString *_signSecret;
|
|
}
|
|
|
|
+ (instancetype)shared {
|
|
static DemoConfigLoader *loader;
|
|
static dispatch_once_t onceToken;
|
|
dispatch_once(&onceToken, ^{
|
|
loader = [[DemoConfigLoader alloc] init];
|
|
});
|
|
return loader;
|
|
}
|
|
|
|
- (instancetype)init {
|
|
if (self = [super init]) {
|
|
[self loadConfig];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)loadConfig {
|
|
NSDictionary *dict = nil;
|
|
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"DemoConfig" ofType:@"plist"];
|
|
if (plistPath.length > 0) {
|
|
dict = [NSDictionary dictionaryWithContentsOfFile:plistPath];
|
|
}
|
|
|
|
_appId = dict[@"appId"] ?: @"";
|
|
_primaryServiceHost = dict[@"primaryServiceHost"] ?: @"";
|
|
_servicePort = [dict[@"servicePort"] integerValue] ?: 443;
|
|
NSString *secret = dict[@"signSecret"] ?: @"";
|
|
_signSecret = secret.length > 0 ? secret : nil;
|
|
}
|
|
|
|
- (NSString *)appId { return _appId; }
|
|
- (NSString *)primaryServiceHost { return _primaryServiceHost; }
|
|
- (NSInteger)servicePort { return _servicePort; }
|
|
- (NSString *)signSecret { return _signSecret; }
|
|
|
|
@end
|