Skip to content

Commit

Permalink
fix unnormal code style
Browse files Browse the repository at this point in the history
fix unnormal code style
  • Loading branch information
dazi.dp committed Feb 3, 2017
1 parent ed3aa3b commit a00f2c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
34 changes: 15 additions & 19 deletions BeeHive/BHConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,34 @@

@interface BHConfig : NSObject

+ (instancetype)shareInstance;

+ (id)get:(NSString *)key;

+(instancetype) shareInstance;
+ (BOOL)has:(NSString *)key;

+(id)get:(NSString *)key;
+ (void)add:(NSDictionary *)parameters;

+(BOOL)has:(NSString *)key;
+ (NSMutableDictionary *)getAll;

+(void) add:(NSDictionary *)parameters;
+ (NSString *)stringValue:(NSString *)key;

+(NSMutableDictionary *) getAll;
+ (NSDictionary *)dictionaryValue:(NSString *)key;

+ (NSInteger)integerValue:(NSString *)key;

+(NSString *)stringValue:(NSString *)key;
+ (float)floatValue:(NSString *)key;

+(NSDictionary *)dictionaryValue:(NSString *)key;
+ (BOOL)boolValue:(NSString *)key;

+(NSInteger)integerValue:(NSString *)key;
+ (NSArray *)arrayValue:(NSString *)key;

+(float)floatValue:(NSString *)key;
+ (void)set:(NSString *)key value:(id)value;

+(BOOL)boolValue:(NSString *)key;
+ (void)set:(NSString *)key boolValue:(BOOL)value;

+(NSArray *)arrayValue:(NSString *)key;

+(void)set:(NSString *)key value:(id)value;

+(void)set:(NSString *)key boolValue:(BOOL)value;

+(void)set:(NSString *)key integerValue:(NSInteger)value;

+(void)clear;
+ (void)set:(NSString *)key integerValue:(NSInteger)value;

+ (void)clear;

@end
32 changes: 15 additions & 17 deletions BeeHive/BHConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ @implementation BHConfig
static BHConfig *_BHConfigInstance;


+(instancetype) shareInstance
+ (instancetype)shareInstance
{
static dispatch_once_t p;

dispatch_once(&p, ^{
_BHConfigInstance = [[[self class] alloc] init];
});

return _BHConfigInstance;
}


+(NSString *)stringValue:(NSString *)key
+ (NSString *)stringValue:(NSString *)key
{
if (![BHConfig shareInstance].config) {
return nil;
Expand All @@ -40,7 +39,7 @@ +(NSString *)stringValue:(NSString *)key
return (NSString *)[[BHConfig shareInstance].config objectForKey:key];
}

+(NSDictionary *)dictionaryValue:(NSString *)key
+ (NSDictionary *)dictionaryValue:(NSString *)key
{
if (![BHConfig shareInstance].config) {
return nil;
Expand All @@ -53,7 +52,7 @@ +(NSDictionary *)dictionaryValue:(NSString *)key
return (NSDictionary *)[[BHConfig shareInstance].config objectForKey:key];
}

+(NSArray *)arrayValue:(NSString *)key
+ (NSArray *)arrayValue:(NSString *)key
{
if (![BHConfig shareInstance].config) {
return nil;
Expand All @@ -66,7 +65,7 @@ +(NSArray *)arrayValue:(NSString *)key
return (NSArray *)[[BHConfig shareInstance].config objectForKey:key];
}

+(NSInteger)integerValue:(NSString *)key
+ (NSInteger)integerValue:(NSString *)key
{
if (![BHConfig shareInstance].config) {
return 0;
Expand All @@ -75,7 +74,7 @@ +(NSInteger)integerValue:(NSString *)key
return [[[BHConfig shareInstance].config objectForKey:key] integerValue];
}

+(float)floatValue:(NSString *)key
+ (float)floatValue:(NSString *)key
{
if (![BHConfig shareInstance].config) {
return 0.0;
Expand All @@ -84,7 +83,7 @@ +(float)floatValue:(NSString *)key
return [(NSNumber *)[[BHConfig shareInstance].config objectForKey:key] floatValue];
}

+(BOOL)boolValue:(NSString *)key
+ (BOOL)boolValue:(NSString *)key
{
if (![BHConfig shareInstance].config) {
return NO;
Expand All @@ -94,7 +93,7 @@ +(BOOL)boolValue:(NSString *)key
}


+(id)get:(NSString *)key
+ (id)get:(NSString *)key
{
if (![BHConfig shareInstance].config) {
@throw [NSException exceptionWithName:@"ConfigNotInitialize" reason:@"config not initialize" userInfo:nil];
Expand All @@ -110,7 +109,7 @@ +(id)get:(NSString *)key
return v;
}

+(BOOL)has:(NSString *)key
+ (BOOL)has:(NSString *)key
{
if (![BHConfig shareInstance].config) {
return NO;
Expand All @@ -123,7 +122,7 @@ +(BOOL)has:(NSString *)key
return YES;
}

+(void)set:(NSString *)key value:(id)value
+ (void)set:(NSString *)key value:(id)value
{
if (![BHConfig shareInstance].config) {
[BHConfig shareInstance].config = [[NSMutableDictionary alloc] initWithCapacity:10];
Expand All @@ -133,18 +132,18 @@ +(void)set:(NSString *)key value:(id)value
}


+(void)set:(NSString *)key boolValue:(BOOL)value
+ (void)set:(NSString *)key boolValue:(BOOL)value
{
[self set:key value:[NSNumber numberWithBool:value]];
}

+(void)set:(NSString *)key integerValue:(NSInteger)value
+ (void)set:(NSString *)key integerValue:(NSInteger)value
{
[self set:key value:[NSNumber numberWithInteger:value]];
}


+(void) add:(NSDictionary *)parameters
+ (void) add:(NSDictionary *)parameters
{
if (![BHConfig shareInstance].config) {
[BHConfig shareInstance].config = [[NSMutableDictionary alloc] initWithCapacity:10];
Expand All @@ -153,13 +152,12 @@ +(void) add:(NSDictionary *)parameters
[[BHConfig shareInstance].config addEntriesFromDictionary:parameters];
}


+(NSDictionary *) getAll
+ (NSDictionary *) getAll
{
return [BHConfig shareInstance].config;
}

+(void)clear
+ (void)clear
{
if ([BHConfig shareInstance].config) {
[[BHConfig shareInstance].config removeAllObjects];
Expand Down

0 comments on commit a00f2c3

Please sign in to comment.