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
This commit is contained in:
Stephan Diederich 2013-06-20 14:20:32 +02:00
parent d3696e5c4f
commit 3c25f25945

View File

@ -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];
}
}