0

I'm trying to use TTTAttributedLabel from this repo: https://github.com/TTTAttributedLabel/TTTAttributedLabel

I have an IBOutlet:

@IBOutlet weak var label: TTTAttributedLabel!

And when I try to add a link to the label using the code example translated to Swift:

self.label.enabledTextCheckingTypes =  NSTextCheckingResult.CheckingType.link.rawValue
self.label.delegate = self

let nsstringText: NSString = "Fork me on GitHub! (https://github.com/mattt/TTTAttributedLabel/)"

self.label.text = nsstringText as String

let range = nsstringText.range(of: "me")
let url = URL(string: "http://github.com/mattt/")

self.label.addLink(to: url, with: range)

I get this error:

-[UILabel setEnabledTextCheckingTypes:]: unrecognized selector sent to instance 0x147e0aa40

Any ideas what am I missing?

pableiros
  • 14,932
  • 12
  • 99
  • 105

1 Answers1

1

@dan was right, I also had this problem and solved it by setting the class of my label in the interface builder to TTTAttributedLabel. Here is picture to see where you need to change class:

Set the class

omanosoft
  • 4,239
  • 1
  • 9
  • 16