I am trying to add a hyperlink in a string. I have a localized string and I put %@ to format my string. When I add the attributed string into my string, the attributed format gives the raw result which is NSLink = "https://www.example.com"
. I could not find an attributed string formatter the same as the string formatter. How can I achieve the same behaviour in my case?
Code:
NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithString:@"Example"];
[str addAttribute: NSLinkAttributeName value: @"https:/www.example.com" range: NSMakeRange(0, str.length)];
NSMutableAttributedString *originalStr = [[NSMutableAttributedString alloc] initWithString: self.pageDescriptions[3].localized];
pageContentViewController.messageText = [NSString stringWithFormat:self.pageDescriptions[index].localized, str];