-
Notifications
You must be signed in to change notification settings - Fork 1
/
FCXOnlineConfig.m
61 lines (46 loc) · 1.73 KB
/
FCXOnlineConfig.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// FCXOnlineConfig.m
// FCXUniversial
//
// Created by 冯 传祥 on 16/3/29.
// Copyright © 2016年 冯 传祥. All rights reserved.
//
#import "FCXOnlineConfig.h"
@implementation FCXOnlineConfig
+ (NSString *)getConfigParams:(NSString *)key {
NSLog(@"\n\n\n请导入UMOnlineConfig库!\n\n\n");
return @"";
}
+ (NSString *)fcxGetConfigParams:(NSString *)key defaultValue:(NSString *)defaultValue {
Class class = NSClassFromString(@"UMOnlineConfig");
if (!class) {
class = self;
}
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSString *versionParam = [NSString stringWithFormat:@"%@_%@", key, appVersion];
NSString *result = [class getConfigParams:versionParam];
if (result == nil) {
result = [class getConfigParams:key];
if (result == nil && defaultValue != nil) {
result = defaultValue;
}
}
return result;
}
+ (NSString *)fcxGetConfigParams:(NSString *)key {
return [self fcxGetConfigParams:key defaultValue:nil];
}
+ (id)fcxGetJSONConfigParams:(NSString *)key {
NSString *paramsString = [self fcxGetConfigParams:key defaultValue:@""];
if (![paramsString isKindOfClass:[NSString class]]) {
return nil;
}
return [NSJSONSerialization JSONObjectWithData:[paramsString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableLeaves error:nil];
}
+ (BOOL)fcxGetBoolConfigParams:(NSString *)key {
return [[self fcxGetConfigParams:key defaultValue:nil] boolValue];
}
+ (BOOL)fcxGetBoolConfigParams:(NSString *)key defaultValue:(NSString*)defaultValue {
return [[self fcxGetConfigParams:key defaultValue:nil] boolValue];
}
@end