JXMessageCell.m 21 KB

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