Open AlexIzh opened 9 years ago
I can't reproduce this crash on the development branch. What is the text in the label and attribute?
try this attributed string: NSMutableAttributedString *string = [NSMutableAttributedString new]; [string appendAttributedString:[[NSAttributedString alloc] initWithString:@"I have "]]; [string appendAttributedString:[[NSAttributedString alloc] initWithString:@"http://google.com/" attributes:@{NSLinkAttributeName:@"http://google.com/"}]]; [string appendAttributedString:[[NSAttributedString alloc] initWithString:@", "]]; [string appendAttributedString:[[NSAttributedString alloc] initWithString:@"http://google.com/" attributes:@{NSLinkAttributeName:[NSURL URLWithString:@"http://google.com/"]}]]; [string appendAttributedString:[[NSAttributedString alloc] initWithString:@", and http://google.com"]]; label.attributedText = string;
Thanks for the quick reply. The problem is because KILabel is assuming NSLinkAttributeName is a string. This is actually fixed on the develop branch where we are checking type of the object (It can be either string or url but url is preferred).
I was planning on releasing the develop branch over the next few days so it's fairly stable if you want to get the fix now. Otherwise I'll close this when I've finalised the 1.1 release.
Thanks
pod 'KILabel', :branch: 'develop'
If string contains NSURL in NSLinkAttributeName then this code is incorrect //KILabel.m:481 NSString *realURL = [text attribute:NSLinkAttributeName atIndex:matchRange.location effectiveRange:nil]; if (realURL == nil) realURL = [plainText substringWithRange:matchRange];//crash