I am trying to add links to UITextViews, so I follow the code for this post . Relevant Objective-C Code
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"This is an example by @marcelofabri_"]; [attributedString addAttribute:NSLinkAttributeName value:@"username://marcelofabri_" range:[[attributedString string] rangeOfString:@"@marcelofabri_"]];
But when I try it in Swift 2 as
var attributedString = NSMutableAttributedString(string: "This is an example by @marcelofabri_") attributedString.addAttribute(NSLinkAttributeName, value: "username://marcelofabri_", range: attributedString.string.rangeOfString("/marcelofabri_"))
I get an error
Cannot call 'addAttribute' using argument list of type '(String, value: String, range: Range?)'
What do I need to change to make this work?
source share