I am using JSQMessages to build a chat app. I am attempting to turn off the "backspace" in the UITextView element by overriding the deleteBackward() function. I could hack at the JSQ framework core, which I want to avoid, and I've tried forced downcasting, but that didn't work either. How can I override a function of an instance of a class (UITextView) that is referenced deep down the tree of the current class (JSQMessagesViewController).
Here is the gist of the code:
In my ChatViewController.swift file
class ChatViewController: JSQMessagesViewController, UICollectionViewDataSource, UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
....
override func viewDidLoad() {
super.viewDidLoad()
var user = PFUser.currentUser()
self.senderId = user.objectId
self.senderDisplayName = user[PF_USER_FULLNAME] as! String
//here's the important line
let base = self.inputToolbar.contentView.textView
let newtexview = base as! UITextViewNB
.....
}
And in my keyboard.swift file
class UITextViewNB: UITextView {
override func deleteBackward() {
// blank because I just want to shut it off
}
}
I'm clearly missing something conceptually.