Permalink
Browse files

Apparently the paragraph style can be nil too, and the previous code …

…was depending on the varargs initializer to catch that
  • Loading branch information...
1 parent 7f38322 commit af7c8b557be09651c6e35572b920a40515c6af17 Justin Spahr-Summers committed Jul 26, 2012
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/UIKit/TUITextView.m
View
@@ -88,15 +88,21 @@ - (void)dealloc {
- (void)_updateDefaultAttributes
{
- NSMutableDictionary *attributes = [@{
- (__bridge id)kCTForegroundColorAttributeName : (__bridge id)self.textColor.CGColor,
- NSParagraphStyleAttributeName : ABNSParagraphStyleForTextAlignment(textAlignment)
- } mutableCopy];
+ NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
+
+ if (self.textColor != nil) {
+ [attributes setObject:(__bridge id)self.textColor.CGColor forKey:(__bridge id)kCTForegroundColorAttributeName];
+ }
if (self.font != nil) {
[attributes setObject:self.font forKey:(__bridge id)kCTFontAttributeName];
}
+ NSParagraphStyle *style = ABNSParagraphStyleForTextAlignment(textAlignment);
+ if (style != nil) {
+ [attributes setObject:style forKey:NSParagraphStyleAttributeName];
+ }
+
renderer.defaultAttributes = attributes;
renderer.markedAttributes = attributes;
}

0 comments on commit af7c8b5

Please sign in to comment.