     }
 
     func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
+
+        guard let textView = self.textView else {
+            return false
+        }
 
         let locationInTextView = gestureRecognizer.location(in: textView)
         guard textView.attachmentAtPoint(locationInTextView) != nil else {

//
@objc class AttachmentGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {

    let textView: TextView
    fileprivate var currentSelectedAttachment: MediaAttachment?

    public init(textView: TextView) {

    }

    func richTextViewWasPressed(_ recognizer: UIGestureRecognizer) {
        guard let textView = self.textView,
            recognizer.state == .recognized else {
                return
        }

        let locationInTextView = recognizer.location(in: textView)
