From 3c25f259459f399f7001c3ee86cf01a91856b86d Mon Sep 17 00:00:00 2001 From: Stephan Diederich Date: Thu, 20 Jun 2013 14:20:32 +0200 Subject: [PATCH] fix warning 'multiple methods length found' * method accepts either NSStrings and NSAttributedString: assert on that * explicitly cast to NSAttributedString to get rid of ambiguity warning --- Classes/BITAttributedLabel.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Classes/BITAttributedLabel.m b/Classes/BITAttributedLabel.m index a7b0be3920..5ca72d11e5 100755 --- a/Classes/BITAttributedLabel.m +++ b/Classes/BITAttributedLabel.m @@ -686,12 +686,15 @@ static inline NSAttributedString * NSAttributedStringBySettingColorFromContext(N [self setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:nil]; return; } - - self.attributedText = text; + NSAssert([text isKindOfClass:[NSAttributedString class]], @"TTTAttributedLabel accepts either NSStrings or NSAttributedStrings"); + NSAttributedString *attributedString = text; + self.attributedText = attributedString; self.links = [NSArray array]; if (self.dataDetectorTypes != UIDataDetectorTypeNone) { - for (NSTextCheckingResult *result in [self detectedLinksInString:[self.attributedText string] range:NSMakeRange(0, [text length]) error:nil]) { + for (NSTextCheckingResult *result in [self detectedLinksInString:[self.attributedText string] + range:NSMakeRange(0, [attributedString length]) + error:nil]) { [self addLinkWithTextCheckingResult:result]; } }