Permalink
Browse files

Remove unnesseary font and foreground value presense assertions

  • Loading branch information...
Collin Ruffenach
Collin Ruffenach committed Mar 2, 2014
1 parent 0a2821f commit 743d81e32e8a2b4f512fbec92e00303fb774726c
Showing with 22 additions and 4 deletions.
  1. +22 −4 STTweetLabel/STTweetLabel.m
@@ -260,17 +260,35 @@ - (void)setValidProtocols:(NSArray *)validProtocols {
}
- (void)setAttributes:(NSDictionary *)attributes {
- if ([attributes objectForKey:NSFontAttributeName] == nil || [attributes objectForKey:NSForegroundColorAttributeName] == nil)
- [NSException raise:NSInvalidArgumentException format:@"Attributes dictionary must contains NSFontAttributeName and NSForegroundColorAttributeName"];
+ if (!attributes[NSFontAttributeName]) {
+ NSMutableDictionary *copy = [attributes mutableCopy];
+ copy[NSFontAttributeName] = self.font;
+ attributes = [NSDictionary dictionaryWithDictionary:copy];
+ }
+
+ if (!attributes[NSForegroundColorAttributeName]) {
+ NSMutableDictionary *copy = [attributes mutableCopy];
+ copy[NSForegroundColorAttributeName] = self.textColor;
+ attributes = [NSDictionary dictionaryWithDictionary:copy];
+ }
_attributesText = attributes;
[self determineHotWords];
}
- (void)setAttributes:(NSDictionary *)attributes hotWord:(STTweetHotWord)hotWord {
- if ([attributes objectForKey:NSFontAttributeName] == nil || [attributes objectForKey:NSForegroundColorAttributeName] == nil)
- [NSException raise:NSInvalidArgumentException format:@"Attributes dictionary must contains NSFontAttributeName and NSForegroundColorAttributeName"];
+ if (!attributes[NSFontAttributeName]) {
+ NSMutableDictionary *copy = [attributes mutableCopy];
+ copy[NSFontAttributeName] = self.font;
+ attributes = [NSDictionary dictionaryWithDictionary:copy];
+ }
+
+ if (!attributes[NSForegroundColorAttributeName]) {
+ NSMutableDictionary *copy = [attributes mutableCopy];
+ copy[NSForegroundColorAttributeName] = self.textColor;
+ attributes = [NSDictionary dictionaryWithDictionary:copy];
+ }
switch (hotWord) {
case STTweetHandle:

0 comments on commit 743d81e

Please sign in to comment.