diff options
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/Views/MessageCell.m | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m index b82d0a1..faf3492 100644 --- a/Juick/Views/MessageCell.m +++ b/Juick/Views/MessageCell.m @@ -78,14 +78,15 @@ attributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]}]; [txt beginEditing]; for (NSDictionary *entity in msg.entities) { - NSUInteger start = [[entity objectForKey:@"start"] unsignedIntegerValue]; - NSUInteger end = [[entity objectForKey:@"end"] unsignedIntegerValue]; + NSUInteger start = [entity[@"start"] unsignedIntegerValue]; + NSUInteger end = [entity[@"end"] unsignedIntegerValue]; + NSString *text = entity[@"text"] ? entity[@"text"] : @""; NSRange currentRange = NSMakeRange(start, end - start); - [txt addAttribute:@"displayText" value:[entity objectForKey:@"text"] range:currentRange]; - if ([[entity objectForKey:@"type"] isEqualToString:@"a"]) { - [txt addAttribute:NSLinkAttributeName value:[entity objectForKey:@"url"] range:currentRange]; + [txt addAttribute:@"displayText" value:text range:currentRange]; + if ([entity[@"type"] isEqualToString:@"a"]) { + [txt addAttribute:NSLinkAttributeName value:entity[@"url"] range:currentRange]; } - if ([[entity objectForKey:@"type"] isEqualToString:@"q"]) { + if ([entity[@"type"] isEqualToString:@"q"]) { [txt addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:currentRange]; NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; paragraphStyle.firstLineHeadIndent = 12.0f; @@ -93,18 +94,18 @@ paragraphStyle.paragraphSpacing = 12.0f; [txt addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:currentRange]; } - if ([[entity objectForKey:@"type"] isEqualToString:@"u"]) { + if ([entity[@"type"] isEqualToString:@"u"]) { [txt addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:currentRange]; } UIFontDescriptor* fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody]; - if ([[entity objectForKey:@"type"] isEqualToString:@"b"]) { + if ([entity[@"type"] isEqualToString:@"b"]) { UIFontDescriptor* boldFontDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold]; UIFont* boldFont = [UIFont fontWithDescriptor:boldFontDescriptor size: 0.0]; [txt addAttribute:NSFontAttributeName value:boldFont range:currentRange]; } - if ([[entity objectForKey:@"type"] isEqualToString:@"i"]) { + if ([entity[@"type"] isEqualToString:@"i"]) { UIFontDescriptor* italicFontDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic]; UIFont* italicFont = [UIFont fontWithDescriptor:italicFontDescriptor size: 0.0]; |