DKWechatHelper/dkhelper/dkhelperDylib/Config/MDConfigManager.m
DKJone b2ddc1ad24 init project
添加初始项目
2019-01-23 11:38:18 +08:00

49 lines
1.1 KiB
Objective-C

// weibo: http://weibo.com/xiaoqing28
// blog: http://www.alonemonkey.com
//
// MDConfigManager.m
// MonkeyDev
//
// Created by AloneMonkey on 2018/4/24.
// Copyright © 2018年 AloneMonkey. All rights reserved.
//
#define CONFIG_FILE_NAME @"MDConfig"
#import "MDConfigManager.h"
@implementation MDConfigManager{
NSString* _filepath;
}
+ (instancetype)sharedInstance{
static MDConfigManager *sharedInstance = nil;
if (!sharedInstance){
sharedInstance = [[MDConfigManager alloc] init];
}
return sharedInstance;
}
- (BOOL)isActive{
_filepath = [[NSBundle mainBundle] pathForResource:CONFIG_FILE_NAME ofType:@"plist"];
if(_filepath == nil){
return NO;
}
return YES;
}
- (NSDictionary*) readConfigByKey:(NSString*) key{
if([self isActive]){
NSDictionary* contentDict = [NSDictionary dictionaryWithContentsOfFile:_filepath];
if([contentDict.allKeys containsObject:key]){
return contentDict[key];
}else{
return nil;
}
}else{
return nil;
}
}
@end