单军华
2018-07-19 83b9d5c682b21d88133f24da0f94dd56bd79e687
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
//
//  HMEmoticon.m
//  表情键盘
//
//  Created by 刘凡 on 16/3/3.
//  Copyright © 2016年 itcast. All rights reserved.
//
 
#import "HMEmoticon.h"
#import "NSBundle+HMEmoticon.h"
#import "NSString+HMEmoji.h"
 
@implementation HMEmoticon
 
#pragma mark - 计算型属性
- (NSString *)imagePath {
    
    if (_type == 1) {
        return nil;
    }
    
    return [NSString stringWithFormat:@"%@/%@", _directory, _png];
}
 
- (void)setCode:(NSString *)code {
    _emoji = code.hm_emoji;
}
 
- (BOOL)isEmoji {
    return _emoji != nil;
}
 
#pragma mark - 构造函数
+ (instancetype)emoticonWithDict:(NSDictionary *)dict {
    id obj = [[self alloc] init];
    
    [obj setValuesForKeysWithDictionary:dict];
    
    return obj;
}
 
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {}
 
- (NSString *)description {
    NSArray *keys = @[@"type", @"chs", @"png", @"code", @"times"];
    
    return [self dictionaryWithValuesForKeys:keys].description;
}
 
#pragma mark - 公共方法
- (NSDictionary *)dictionary {
    NSArray *keys = @[@"type", @"chs", @"directory", @"png", @"code", @"times"];
    
    return [self dictionaryWithValuesForKeys:keys];
}
 
@end