BaseDomain.m
1.43 KB
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
//
// BaseDomain.m
// IM_ios_client
//
// Created by 顾俊生 on 16/1/4.
// Copyright © 2016年 xiniu. All rights reserved.
//
#import "BaseDomain.h"
@implementation BaseDomain
@synthesize fields;
- (instancetype)init
{
fields = [NSMutableDictionary new];
return self;
}
#pragma mark - 共同的设置Domain元素的方法
/*
itemObj:元素值
itemKey:元素的值在元素所属Domain的字典中对应的Key
selfFields:元素所属Domain的字典
selfKey:元素所属Domain的字典在BaseDomain中的Key
*/
-(void)setItemObj:(id)itemObj itemKey:(id<NSCopying>)itemKey selfFields:(NSMutableDictionary *)selfFields selfKey:(id<NSCopying>)selfKey
{
[selfFields setObject:itemObj forKey:itemKey];
[fields setObject:selfFields forKey:selfKey];
}
#pragma mark - 根据Domain的字典在BaseDomain中的Key获得Domain的字典
-(NSMutableDictionary *)getDomainDicByKey:(NSString *)domainKey
{
NSMutableDictionary *dic_self = [[NSMutableDictionary alloc]init];
if ([fields objectForKey:domainKey]) {
dic_self = [NSMutableDictionary dictionaryWithDictionary:[fields objectForKey:domainKey]];
}
return dic_self;
}
#pragma mark - 判读字典中是否存在某个key
-(BOOL)keyExistInDictionary:(NSMutableDictionary *)dic key:(NSString *)key
{
if (![dic isKindOfClass:[NSNull class]] && dic.allKeys.count > 0 && [[dic allKeys] containsObject:key]) {
return YES;
}
return NO;
}
@end