JXMessageCell.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. //
  2. // JXMessageCell.m
  3. // shiku_im
  4. //
  5. // Created by Apple on 16/10/10.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JXMessageCell.h"
  9. #import "emojiViewController.h"
  10. #import "EmojiTextAttachment.h"
  11. //#define TEXT_MAX_HEIGHT 500.0f
  12. @implementation JXMessageCell
  13. - (void)awakeFromNib {
  14. [super awakeFromNib];
  15. // self.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, 55);
  16. }
  17. - (void)dealloc {
  18. [self.readDelTimer invalidate];
  19. self.readDelTimer = nil;
  20. }
  21. -(void)creatUI{
  22. _messageConent=[[JXEmoji alloc] init];
  23. _messageConent.userInteractionEnabled = YES;
  24. _messageConent.lineBreakMode = NSLineBreakByWordWrapping;
  25. _messageConent.numberOfLines = 0;
  26. _messageConent.backgroundColor = [UIColor clearColor];
  27. [self.bubbleBg addSubview:_messageConent];
  28. _timeIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
  29. _timeIndexLabel.layer.cornerRadius = _timeIndexLabel.frame.size.width / 2;
  30. _timeIndexLabel.layer.masksToBounds = YES;
  31. _timeIndexLabel.textColor = [UIColor whiteColor];
  32. _timeIndexLabel.backgroundColor = HEXCOLOR(0x02d8c9);
  33. _timeIndexLabel.textAlignment = NSTextAlignmentCenter;
  34. _timeIndexLabel.text = @"0";
  35. _timeIndexLabel.font = [UIFont systemFontOfSize:12.0];
  36. _timeIndexLabel.hidden = YES;
  37. [self.contentView addSubview:_timeIndexLabel];
  38. UITapGestureRecognizer * tapPress = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dotapPress:)];
  39. [self.contentView addGestureRecognizer:tapPress];
  40. _messageConent.text = self.msg.content;
  41. }
  42. - (void)dotapPress:(UITapGestureRecognizer *)tap {
  43. if (self.block) {
  44. self.block(self.msg);
  45. }
  46. }
  47. -(void)setCellData{
  48. [super setCellData];
  49. JLBubbleManager *bubbleManager;
  50. if (self.msg.isGroup) {
  51. memberData *data = [[memberData alloc] init];
  52. data.roomId = self.room.roomId;
  53. data = [data getCardNameById:self.msg.fromUserId];
  54. if (data.bubbleFontId.length <= 0) {
  55. bubbleManager = [JLBubbleManager sharedManager];
  56. bubbleManager.id = @"0";
  57. }else {
  58. bubbleManager = [[JLBubbleManager sharedManager] fechGradeByBubbleFontId:data.bubbleFontId];
  59. }
  60. // NSLog(@"ID--%@---fromUserId%@--%@", data.bubbleFontId,self.msg.fromUserId,bubbleManager);
  61. }else {
  62. // 单聊
  63. // 从朋友表里获取
  64. JXUserObject *user;
  65. if (self.msg.isMySend) {
  66. user = [[JXUserObject sharedInstance] getUserById:MY_USER_ID];
  67. }else {
  68. user = [[JXUserObject sharedInstance] getUserById:self.msg.fromUserId];
  69. }
  70. bubbleManager = [[JLBubbleManager sharedManager] fechGradeByBubbleFontId:user.bubbleFontId];
  71. }
  72. if (bubbleManager == nil) {
  73. _messageConent.font = [[JLBubbleManager sharedManager] getBubbleFontNameIndex:-1];
  74. _messageConent.textColor = [[JLBubbleManager sharedManager] getBubbleFontColor:@""];
  75. }else {
  76. _messageConent.font = [[JLBubbleManager sharedManager] getBubbleFontNameIndex:[bubbleManager.code intValue]];
  77. _messageConent.textColor = [[JLBubbleManager sharedManager] getBubbleFontColor:bubbleManager.color];
  78. }
  79. _messageConent.textColor =[UIColor blackColor];
  80. // 设置显示字体
  81. _messageConent.frame = CGRectMake(0, 0, 200, 20);
  82. if (self.msg.objectId.length > 0) {
  83. _messageConent.atUserIdS = self.msg.objectId;
  84. }
  85. if ([self.msg.isReadDel boolValue] && ([self.msg.fileName length] <= 0 || [self.msg.fileName intValue] <= 0) && !self.msg.isMySend) {
  86. _messageConent.userInteractionEnabled = NO;
  87. _messageConent.text = [NSString stringWithFormat:@"%@ T", Localized(@"JX_ClickAndView")];
  88. // _messageConent.textColor = HEXCOLOR(0x0079FF);
  89. _timeIndexLabel.hidden = YES;
  90. }else {
  91. _messageConent.userInteractionEnabled = YES;
  92. // _messageConent.textColor = HEXCOLOR(0x333333);
  93. // _messageConent.textColor = [UIColor whiteColor];
  94. if ([self.msg.content containsString:@"===jixin"]) {
  95. NSArray *typeArr = [self.msg.content componentsSeparatedByString:@"===jixin"];
  96. _messageConent.text=[typeArr firstObject];
  97. }else{
  98. _messageConent.text = self.msg.content;
  99. }
  100. // NSLog(@"000000%@",self.msg.content);
  101. _timeIndexLabel.hidden = YES;
  102. if (!self.msg.isMySend && [self.msg.fileName isKindOfClass:[NSString class]] && [self.msg.fileName length] > 0 && [self.msg.fileName intValue] > 0) {
  103. self.timeIndexLabel.hidden = NO;
  104. NSString *messageR = [self.msg.content stringByReplacingOccurrencesOfString:@"\r" withString:@""]; //去掉回车键
  105. NSString *messageN = [messageR stringByReplacingOccurrencesOfString:@"\n" withString:@""]; //去掉回车键
  106. NSString *messageText = [messageN stringByReplacingOccurrencesOfString:@" " withString:@""]; //去掉空格
  107. NSMutableAttributedString * textC = [self changeEmjoyText:messageText];
  108. [textC addAttribute:NSFontAttributeName value:SYSFONT(g_constant.chatFont) range:NSMakeRange(0, textC.length)];
  109. CGSize size = [textC boundingRectWithSize:CGSizeMake(_messageConent.frame.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size;
  110. NSInteger count = size.height / _messageConent.font.lineHeight;
  111. // NSLog(@"countcount === %ld-----%f-----%@",count,[[NSDate date] timeIntervalSince1970],self.msg.fileName);
  112. // NSLog(@"countcount === %ld,,,,%f,,,,%@",count,[[NSDate date] timeIntervalSince1970], self.msg.fileName);
  113. count = count * 10 - ([[NSDate date] timeIntervalSince1970] - [self.msg.fileName longLongValue]);
  114. self.timerIndex = count;
  115. // NSLog(@"countcount1 === %ld",count);
  116. if (count > 0) {
  117. self.timeIndexLabel.text = [NSString stringWithFormat:@"%ld",count];
  118. if (!self.readDelTimer) {
  119. self.readDelTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES];
  120. }
  121. }else {
  122. self.msg.fileName = @"0";
  123. //阅后即焚通知
  124. [g_notify postNotificationName:kCellReadDelNotification object:self.msg];
  125. [self deleteMsg:self.msg];
  126. }
  127. }
  128. }
  129. [self creatBubbleBg];
  130. }
  131. static CGFloat kuangkkHHH;
  132. -(void)creatBubbleBg{
  133. CGSize textSize = _messageConent.frame.size;
  134. int n = textSize.width;
  135. if ([_messageConent.text containsString:@"----------【"]) {
  136. kuangkkHHH=65.0;
  137. } //聊天长度反正就是算错了,强行改
  138. int inset = 3;
  139. if(self.msg.isMySend){
  140. self.bubbleBg.frame=CGRectMake(CGRectGetMinX(self.headImage.frame)-INSETS*2-inset*2-n-CHAT_WIDTH_ICON, INSETS,_kuangHHH+ n+INSETS*2+inset*2, textSize.height+INSETS*2);
  141. self.bubbleBgImageView.frame = CGRectMake(0, 0,n+INSETS*2+inset*2, textSize.height+INSETS*2+INSETS);
  142. [_messageConent setFrame:CGRectMake(INSETS*0.4 + 3 +5, 10,_kuangHHH+ n + 5, textSize.height)];
  143. // [_messageConent setFrame:CGRectMake(INSETS*0.4 + 3, INSETS, n + 5, textSize.height+50)];
  144. _timeIndexLabel.frame = CGRectMake(self.bubbleBg.frame.origin.x - 30, self.bubbleBg.frame.origin.y, 20, 20);
  145. }else
  146. {
  147. self.bubbleBg.frame=CGRectMake(CGRectGetMaxX(self.headImage.frame) + CHAT_WIDTH_ICON, INSETS2(self.msg.isGroup)+9, n+INSETS*2+inset*2, textSize.height+INSETS*2);
  148. self.bubbleBgImageView.frame =CGRectMake(0, 2, n+INSETS*2+inset*2, textSize.height+INSETS*2+20);
  149. [_messageConent setFrame:CGRectMake(INSETS + 3, 10, n+5, textSize.height)];
  150. _timeIndexLabel.frame = CGRectMake(CGRectGetMaxX(self.bubbleBg.frame) + 10, self.bubbleBg.frame.origin.y, 20, 20);
  151. // _messageConent.textAlignment = NSTextAlignmentLeft;
  152. }
  153. if (self.msg.isShowTime) {
  154. CGRect frame = self.bubbleBg.frame;
  155. frame.origin.y = self.bubbleBg.frame.origin.y + 40;
  156. self.bubbleBg.frame = frame;
  157. _timeIndexLabel.frame = CGRectMake(_timeIndexLabel.frame.origin.x, self.bubbleBg.frame.origin.y, 20, 20);
  158. }
  159. }
  160. - (void)setBackgroundImage {
  161. [super setBackgroundImage];
  162. if (!self.msg.isMySend && [self.msg.fileName isKindOfClass:[NSString class]] && [self.msg.fileName length] > 0 && [self.msg.fileName intValue] >= 0 && [self.msg.type intValue] == kWCMessageTypeText) {
  163. self.isDidMsgCell = YES;
  164. }
  165. if ([self.msg.isReadDel boolValue] && !self.msg.isMySend && self.isDidMsgCell) {
  166. [self drawReadDelView:YES];
  167. self.isDidMsgCell = NO;
  168. }
  169. }
  170. //复制信息到剪贴板
  171. - (void)myCopy{
  172. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  173. [pasteboard setString:self.msg.content];
  174. }
  175. + (float)getChatCellHeight:(JXMessageObject *)msg {
  176. //NSLog(@"----%@",msg.content);
  177. if ([msg.chatMsgHeight floatValue] > 1) {
  178. if ([msg.content containsString:@"--------------------------------------------------"]) {
  179. kuangkkHHH=65.0;
  180. }
  181. CGFloat chatMsgHeight = [msg.chatMsgHeight floatValue]+kuangkkHHH;
  182. return chatMsgHeight;
  183. }
  184. float n = 0.0;
  185. JXEmoji *messageConent=[[JXEmoji alloc]initWithFrame:CGRectMake(0, 0, 200, 20)];
  186. messageConent.backgroundColor = [UIColor clearColor];
  187. // messageConent.userInteractionEnabled = NO;
  188. messageConent.numberOfLines = 0;
  189. messageConent.lineBreakMode = NSLineBreakByWordWrapping;//UILineBreakModeWordWrap;
  190. JLBubbleManager *bubbleManager;
  191. if (msg.isGroup) {
  192. memberData *data = [[memberData alloc] init];
  193. data.roomId = msg.toId;
  194. data = [data getCardNameById:msg.fromUserId];
  195. if (data.bubbleFontId.length <= 0) {
  196. bubbleManager = [JLBubbleManager sharedManager];
  197. bubbleManager.id = @"0";
  198. }else {
  199. bubbleManager = [[JLBubbleManager sharedManager] fechGradeByBubbleFontId:data.bubbleFontId];
  200. }
  201. // NSLog(@"ID--%@---fromUserId%@--%@", data.bubbleFontId,self.msg.fromUserId,bubbleManager);
  202. }else {
  203. // 单聊
  204. // 从朋友表里获取
  205. JXUserObject *user;
  206. if (msg.isMySend) {
  207. user = [[JXUserObject sharedInstance] getUserById:MY_USER_ID];
  208. }else {
  209. user = [[JXUserObject sharedInstance] getUserById:msg.fromUserId];
  210. }
  211. bubbleManager = [[JLBubbleManager sharedManager] fechGradeByBubbleFontId:user.bubbleFontId];
  212. }
  213. if (bubbleManager == nil) {
  214. messageConent.font = [[JLBubbleManager sharedManager] getBubbleFontNameIndex:-1];
  215. messageConent.textColor = [[JLBubbleManager sharedManager] getBubbleFontColor:@""];
  216. }else {
  217. messageConent.font = [[JLBubbleManager sharedManager] getBubbleFontNameIndex:[bubbleManager.code intValue]];
  218. messageConent.textColor = [[JLBubbleManager sharedManager] getBubbleFontColor:bubbleManager.color];
  219. }
  220. messageConent.offset = -12;
  221. messageConent.frame = CGRectMake(0, 0, 200, 20);
  222. if ([msg.isReadDel boolValue] && [msg.fileName intValue] <= 0 && !msg.isMySend) {
  223. messageConent.text = [NSString stringWithFormat:@"%@ T", Localized(@"JX_ClickAndView")];
  224. }else {
  225. messageConent.text = msg.content;
  226. }
  227. if (msg.isGroup && !msg.isMySend) {
  228. n = messageConent.frame.size.height+10*3 + 27;
  229. if (msg.isShowTime) {
  230. n=messageConent.frame.size.height+10*3 + 40 + 20;
  231. }
  232. n += GROUP_CHAT_INSET;
  233. }else {
  234. n= messageConent.frame.size.height+10*3 + 10;
  235. if (msg.isShowTime) {
  236. n=messageConent.frame.size.height+10*3 + 40 + 10;
  237. }
  238. }
  239. // NSLog(@"heightForRowAtIndexPath_%d,%d:=%@",indexPath.row,n,_messageConent.text);
  240. if(n<55)
  241. n = 55+10;
  242. if (msg.isShowTime) {
  243. if(n<95)
  244. n = 95+10;
  245. }
  246. msg.chatMsgHeight = [NSString stringWithFormat:@"%f",n];
  247. if ([msg.content containsString:@"===jixinJXBigRellV"]){
  248. msg.chatMsgHeight = [NSString stringWithFormat:@"%f",n]; //--20
  249. }
  250. if (!msg.isNotUpdateHeight) {
  251. [msg updateChatMsgHeight];
  252. }
  253. // NSLog(@"高度%f--内容高度%f--内容%@", n, messageConent.frame.size.height,msg.content);
  254. return n;
  255. }
  256. -(void)didTouch:(UIButton*)button{
  257. if ([self.msg.isReadDel boolValue] && [self.msg.fileName intValue] <= 0 && !self.msg.isMySend) {
  258. [self.msg sendAlreadyReadMsg];
  259. self.msg.fileName = [NSString stringWithFormat:@"%f", [[NSDate date] timeIntervalSince1970]];
  260. [self.msg updateFileName];
  261. self.timeIndexLabel.hidden = NO;
  262. _messageConent.text = self.msg.content;
  263. // NSString *messageR = [self.msg.content stringByReplacingOccurrencesOfString:@"\r" withString:@""]; //去掉回车键
  264. // NSString *messageN = [messageR stringByReplacingOccurrencesOfString:@"\n" withString:@""]; //去掉回车键
  265. // NSString *messageText = [messageN stringByReplacingOccurrencesOfString:@" " withString:@""]; //去掉空格
  266. // CGSize size = [messageText boundingRectWithSize:CGSizeMake(_messageConent.frame.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:SYSFONT(g_constant.chatFont)} context:nil].size;
  267. // NSInteger count = size.height / _messageConent.font.lineHeight;
  268. // self.msg.fileName = [NSString stringWithFormat:@"%ld", count * 10];
  269. self.isDidMsgCell = YES;
  270. self.msg.chatMsgHeight = [NSString stringWithFormat:@"0"];
  271. [self.msg updateChatMsgHeight];
  272. [g_notify postNotificationName:kCellMessageReadDelNotifaction object:[NSNumber numberWithInt:self.indexNum]];
  273. // self.readDelTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES];
  274. }
  275. }
  276. - (void)timerAction:(NSTimer *)timer {
  277. if (self.timerIndex <= 0) {
  278. [self.readDelTimer invalidate];
  279. self.readDelTimer = nil;
  280. self.msg.fileName = @"0";
  281. //阅后即焚通知
  282. [g_notify postNotificationName:kCellReadDelNotification object:self.msg];
  283. [self deleteMsg:self.msg];
  284. return;
  285. }
  286. self.timeIndexLabel.text = [NSString stringWithFormat:@"%ld",-- self.timerIndex];
  287. // self.msg.fileName = self.timeIndexLabel.text;
  288. // [self.msg updateFileName];
  289. }
  290. - (void)deleteMsg:(JXMessageObject *)msg{
  291. if ([self.msg.isReadDel boolValue]) {
  292. if ([self.msg.fileName intValue] > 0) {
  293. return;
  294. }
  295. //渐变隐藏
  296. [UIView animateWithDuration:2.f animations:^{
  297. self.bubbleBg.alpha = 0;
  298. self.timeIndexLabel.alpha = 0;
  299. self.readImage.alpha = 0;
  300. self.burnImage.alpha = 0;
  301. } completion:^(BOOL finished) {
  302. //动画结束后删除UI
  303. [self.delegate performSelectorOnMainThread:self.readDele withObject:msg waitUntilDone:NO];
  304. self.bubbleBg.alpha = 1;
  305. self.timeIndexLabel.alpha = 1;
  306. self.readImage.alpha = 1;
  307. self.burnImage.alpha = 1;
  308. }];
  309. }
  310. }
  311. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  312. [super setSelected:selected animated:animated];
  313. // Configure the view for the selected state
  314. }
  315. #pragma mark - 有表情的txt 转换成 含图片的str
  316. - (NSMutableAttributedString *)changeEmjoyText:(NSString *)text {
  317. NSMutableAttributedString *conStr = [[NSMutableAttributedString alloc] init];
  318. NSMutableArray *arr = [NSMutableArray array];
  319. [self getImageRange:text array:arr];
  320. if (arr.count > 1) {
  321. for (NSInteger i = 0; i < arr.count; i ++) {
  322. NSString *str = arr[i];
  323. NSInteger n;
  324. if ([str hasPrefix:@"["]&&[str hasSuffix:@"]"] && [g_faceVC.shortNameArrayE containsObject:str]) {
  325. n = [g_faceVC.shortNameArrayE indexOfObject:str];
  326. NSDictionary *dic = [g_constant.emojiArray objectAtIndex:n];
  327. EmojiTextAttachment *attachment = [[EmojiTextAttachment alloc] init];
  328. attachment.emojiTag = str;
  329. attachment.image = [UIImage imageNamed:dic[@"filename"]];
  330. attachment.bounds = CGRectMake(0, -4, 23, 23);
  331. [conStr appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
  332. }else {
  333. [conStr appendAttributedString:[[NSAttributedString alloc] initWithString:str attributes:@{NSFontAttributeName:self.messageConent.font}]];
  334. }
  335. }
  336. }else {
  337. return [[NSMutableAttributedString alloc] initWithString:text];
  338. }
  339. return conStr;
  340. }
  341. //将表情和文字分开,装进array
  342. -(void)getImageRange:(NSString*)message array: (NSMutableArray*)array {
  343. NSRange range=[message rangeOfString: @"["];
  344. NSRange range1=[message rangeOfString: @"]"];
  345. NSRange atRange = [message rangeOfString:@"@"];
  346. //判断当前字符串是否还有表情的标志。
  347. if (((range.length>0 && range1.length>0) || atRange.length>0) && range1.location > range.location) {
  348. if (range.length>0 && range1.length>0) {
  349. // self.contentEmoji = YES;
  350. // if (range.location > 0) {
  351. // [array addObject:[message substringToIndex:range.location]];
  352. // [array addObject:[message substringWithRange:NSMakeRange(range.location, range1.location+1-range.location)]];
  353. // NSString *str=[message substringFromIndex:range1.location+1];
  354. // [self getImageRange:str array:array];
  355. // }else {
  356. // NSString *nextstr=[message substringWithRange:NSMakeRange(range.location, range1.location+1-range.location)];
  357. // //排除文字是“”的
  358. // if (![nextstr isEqualToString:@""]) {
  359. // [array addObject:nextstr];
  360. // NSString *str=[message substringFromIndex:range1.location+1];
  361. // [self getImageRange:str array:array];
  362. // }else {
  363. // return;
  364. // }
  365. // }
  366. if (range.location > 0) {
  367. NSString *str = [message substringToIndex:range.location];
  368. NSString *str1 = [message substringFromIndex:range.location];
  369. [array addObject:str];
  370. [self getImageRange:str1 array:array];
  371. }else {
  372. NSString *emojiString = [message substringWithRange:NSMakeRange(range.location + 1, range1.location - 1)];
  373. BOOL isEmoji = NO;
  374. NSString *str;
  375. NSString *str1;
  376. for (NSMutableDictionary *dic in g_constant.emojiArray) {
  377. NSString *emoji = [dic objectForKey:@"english"];
  378. if ([emoji isEqualToString:emojiString]) {
  379. isEmoji = YES;
  380. break;
  381. }
  382. }
  383. if (isEmoji) {
  384. str = [message substringWithRange:NSMakeRange(range.location, range1.location + 1)];
  385. str1 = [message substringFromIndex:range1.location + 1];
  386. [array addObject:str];
  387. }else{
  388. NSString *posString = [message substringWithRange:NSMakeRange(range.location + 1, range1.location)];
  389. NSRange posRange = [posString rangeOfString:@"["];
  390. if (posRange.location != NSNotFound) {
  391. str = [message substringToIndex:posRange.location + 1];
  392. str1 = [message substringFromIndex:posRange.location + 1];
  393. [array addObject:str];
  394. }else{
  395. str = [message substringToIndex:range1.location + 1];
  396. str1 = [message substringFromIndex:range1.location + 1];
  397. [array addObject:str];
  398. }
  399. }
  400. [self getImageRange:str1 array:array];
  401. }
  402. } else if (atRange.length>0) {
  403. if (atRange.location > 0) {
  404. [array addObject:[message substringToIndex:atRange.location]];
  405. [array addObject:[message substringWithRange:NSMakeRange(atRange.location, 1)]];
  406. NSString *str=[message substringFromIndex:atRange.location+1];
  407. [self getImageRange:str array:array];
  408. }else{
  409. [array addObject:[message substringWithRange:NSMakeRange(atRange.location, 1)]];
  410. NSString *str=[message substringFromIndex:atRange.location+1];
  411. [self getImageRange:str array:array];
  412. }
  413. }else if (message != nil) {
  414. [array addObject:message];
  415. }
  416. }
  417. else if (range.length>0 && range1.length>0 && range1.location < range.location){
  418. NSString *str = [message substringToIndex:range1.location + 1];
  419. NSString *str1 = [message substringFromIndex:range1.location + 1];
  420. [array addObject:str];
  421. [self getImageRange:str1 array:array];
  422. }
  423. else if (message != nil) {
  424. [array addObject:message];
  425. }
  426. }
  427. @end