From 2f05dcc2c54add031968bdb9835b08c738592d62 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 3 May 2017 10:16:44 -0400 Subject: [PATCH] fix crash when viewing undisplayable text (can't init attributed string with nil) // FREEBIE --- .../src/ViewControllers/InboxTableViewCell.m | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Signal/src/ViewControllers/InboxTableViewCell.m b/Signal/src/ViewControllers/InboxTableViewCell.m index 13ec2f167..84ba22ec9 100644 --- a/Signal/src/ViewControllers/InboxTableViewCell.m +++ b/Signal/src/ViewControllers/InboxTableViewCell.m @@ -98,15 +98,19 @@ NS_ASSUME_NONNULL_BEGIN : [UIColor lightGrayColor]), }]]; } - [snippetText appendAttributedString:[[NSAttributedString alloc] initWithString:[[DisplayableTextFilter new] displayableText:thread.lastMessageLabel] - attributes:@{ - NSFontAttributeName : (thread.hasUnreadMessages - ? [UIFont ows_mediumFontWithSize:12] - : [UIFont ows_regularFontWithSize:12]), - NSForegroundColorAttributeName : (thread.hasUnreadMessages - ? [UIColor ows_blackColor] - : [UIColor lightGrayColor]), - }]]; + NSString *displayableText = [[DisplayableTextFilter new] displayableText:thread.lastMessageLabel]; + if (displayableText) { + [snippetText appendAttributedString:[[NSAttributedString alloc] + initWithString:displayableText + attributes:@{ + NSFontAttributeName : (thread.hasUnreadMessages + ? [UIFont ows_mediumFontWithSize:12] + : [UIFont ows_regularFontWithSize:12]), + NSForegroundColorAttributeName : + (thread.hasUnreadMessages ? [UIColor ows_blackColor] + : [UIColor lightGrayColor]), + }]]; + } } NSAttributedString *attributedDate = [self dateAttributedString:thread.lastMessageDate];