 
     fileprivate func detectAttachmentRemoved(in range:NSRange) {
         textStore.enumerateAttachmentsOfType(TextAttachment.self, range: range) { (attachment, range, stop) in
-            self.attachmentsDelegate?.storage(self, deletedAttachmentWithID: attachment.identifier)
+            self.attachmentsDelegate.storage(self, deletedAttachmentWithID: attachment.identifier)
         }
     }
 

    /// - Returns: the preprocessed string.
    ///
    fileprivate func preprocessAttachmentsForInsertion(_ attributedString: NSAttributedString) -> NSAttributedString {
        
        let fullRange = NSRange(location: 0, length: attributedString.length)
        let finalString = NSMutableAttributedString(attributedString: attributedString)
        
        attributedString.enumerateAttribute(NSAttachmentAttributeName, in: fullRange, options: []) { (object, range, stop) in

            guard let object = object, !(object is LineAttachment), !(object is CommentAttachment) else {
                return
            }

            guard let attachmentsDelegate = attachmentsDelegate else {
                assertionFailure("This class can't really handle not having an image provider set.")
                return
            }



    // MARK: - Attachments

    var attachmentsDelegate: TextStorageAttachmentsDelegate!

    open func TextAttachments() -> [TextAttachment] {
        let range = NSMakeRange(0, length)
