I want to make a UILabel
with some text with a click-able links in it. Not links to webpages but to actions like I do with an UIButton
. So I used TTTAttributedLabel
which is working perfectly with Objective C
. Now I want to do the same in Swift
, so I wrote the below code:
self.someLabel.text = NSLocalizedString("Lost? Learn more.", comment: "")
let range = self.someLabel.text!.rangeOfString(NSLocalizedString("Learn more", comment:""))
self.someLabel.addLinkToURL (NSURL(string:"action://Learn more"), withRange:NSRange (range))
However, I cannot make the link work in Swift
. I am getting the error: “Missing argument for parameter 'host' in call”
for the last line.
String.rangeOfString
returnsRange
, butNSString.rangeOfString
returnsNSRange
. So the following code should work: