ChatEmojiIcons.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // ChatEmojiIcons.m
  3. // BuguLive
  4. //
  5. // Created by 朱庆彬 on 2017/8/15.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "ChatEmojiIcons.h"
  9. @implementation ChatEmojiIcons
  10. //获取表情包
  11. + (NSArray *)emojis
  12. {
  13. static NSArray *_emojis;
  14. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  15. // 处理耗时操作的代码块...
  16. NSString *emojiFilePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Emoji.plist"];
  17. NSDictionary *emojiDic = [[NSDictionary alloc] initWithContentsOfFile:emojiFilePath];
  18. NSMutableArray *array = [NSMutableArray array];
  19. for (NSInteger i = 1; i < 105; i++)
  20. {
  21. [array addObject:[emojiDic valueForKey:[NSString stringWithFormat:@"[em_%@]", @(i)]]];
  22. }
  23. //通知主线程刷新
  24. dispatch_async(dispatch_get_main_queue(), ^{
  25. _emojis = array;
  26. });
  27. });
  28. return _emojis;
  29. }
  30. + (NSInteger)getEmojiPopCount
  31. {
  32. return [[self class] emojis].count;
  33. }
  34. + (NSString *)getEmojiNameByTag:(NSInteger)tag
  35. {
  36. NSArray *emojis = [[self class] emojis];
  37. return emojis[tag];
  38. }
  39. + (NSString *)getEmojiPopIMGNameByTag:(NSInteger)tag
  40. {
  41. NSString *name = [[self class] getEmojiNameByTag:tag];
  42. return [[self class] imgNameWithName:name];
  43. }
  44. + (NSString *)getEmojiPopNameByTag:(NSInteger)tag
  45. {
  46. NSString *key = [NSString stringWithFormat:@"%@", [self getEmojiNameByTag:tag]];
  47. return NSLocalizedString(key, @"");
  48. }
  49. + (NSString *)imgNameWithName:(NSString *)name
  50. {
  51. return [NSString stringWithFormat:@"%@", name];
  52. }
  53. @end