I'm trying to create a class which only purpose is to implement UITextViewDelegate, but for some reason the method shouldChangeTextInRange is never called, here is my code:
public class TTextViewDelegate: NSObject, UITextViewDelegate {
public func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool {
print("!!!!!! Should change text in range: \(text)")
return true
}
}
And in my viewcontroller:
textView.delegate = TTextViewDelegate()
Why does UITextViewDelegate only work if it is implemented in a viewcontroller?