summaryrefslogtreecommitdiff
path: root/Juick/Views
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Views')
-rw-r--r--Juick/Views/MessageCell.m20
1 files changed, 10 insertions, 10 deletions
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m
index faf3492..2686adf 100644
--- a/Juick/Views/MessageCell.m
+++ b/Juick/Views/MessageCell.m
@@ -77,16 +77,16 @@
initWithString:msg.text
attributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]}];
[txt beginEditing];
- for (NSDictionary *entity in msg.entities) {
- NSUInteger start = [entity[@"start"] unsignedIntegerValue];
- NSUInteger end = [entity[@"end"] unsignedIntegerValue];
- NSString *text = entity[@"text"] ? entity[@"text"] : @"";
+ for (Entity *entity in msg.entities) {
+ NSUInteger start = entity.start ? [entity.start unsignedIntegerValue] : 0;
+ NSUInteger end = entity.end ? [entity.end unsignedIntegerValue] : 0;
+ NSString *text = entity.text ? entity.text : @"";
NSRange currentRange = NSMakeRange(start, end - start);
[txt addAttribute:@"displayText" value:text range:currentRange];
- if ([entity[@"type"] isEqualToString:@"a"]) {
- [txt addAttribute:NSLinkAttributeName value:entity[@"url"] range:currentRange];
+ if ([entity.type isEqualToString:@"a"]) {
+ [txt addAttribute:NSLinkAttributeName value:entity.link range:currentRange];
}
- if ([entity[@"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;
@@ -94,18 +94,18 @@
paragraphStyle.paragraphSpacing = 12.0f;
[txt addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:currentRange];
}
- if ([entity[@"type"] isEqualToString:@"u"]) {
+ if ([entity.type isEqualToString:@"u"]) {
[txt addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:currentRange];
}
UIFontDescriptor* fontDescriptor = [UIFontDescriptor
preferredFontDescriptorWithTextStyle:UIFontTextStyleBody];
- if ([entity[@"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[@"type"] isEqualToString:@"i"]) {
+ if ([entity.type isEqualToString:@"i"]) {
UIFontDescriptor* italicFontDescriptor = [fontDescriptor
fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic];
UIFont* italicFont = [UIFont fontWithDescriptor:italicFontDescriptor size: 0.0];