         }
     }
 
-    private func handleGesture(for detectorType: DetectorType, value: Any?) {
-
-        switch detectorType {
-        case .address:
+    private func handleGesture(for detectorType: DetectorType, value: MessageTextCheckingType) {
+        
+        switch value {
+        case let .addressComponents(addressComponents):
             var transformedAddressComponents = [String: String]()
-            guard let addressComponents = value as? [NSTextCheckingKey: String] else { return }
+            guard let addressComponents = addressComponents else { return }
             addressComponents.forEach { (key, value) in
                 transformedAddressComponents[key.rawValue] = value
             }
             handleAddress(transformedAddressComponents)
-        case .phoneNumber:
-            guard let phoneNumber = value as? String else { return }
+        case let .phoneNumber(phoneNumber):
+            guard let phoneNumber = phoneNumber else { return }
             handlePhoneNumber(phoneNumber)
-        case .date:
-            guard let date = value as? Date else { return }
+        case let .date(date):
+            guard let date = date else { return }
             handleDate(date)
-        case .url:
-            guard let url = value as? URL else { return }
+        case let .link(url):
+            guard let url = url else { return }
             handleURL(url)
         }
     }

        return textStorage
    }()

    private lazy var rangesForDetectors: [DetectorType: [(NSRange, Any?)]] = [:]

    // MARK: - Public Properties


        for result in checkingResults {

            switch result.resultType {
            case .address:
                var ranges = rangesForDetectors[.address] ?? []
                let tuple: (NSRange, MessageTextCheckingType) = (result.range, .addressComponents(result.addressComponents))
                ranges.append(tuple)
                rangesForDetectors.updateValue(ranges, forKey: .address)
            case .date:
                var ranges = rangesForDetectors[.date] ?? []
                let tuple: (NSRange, MessageTextCheckingType) = (result.range, .date(result.date))
                ranges.append(tuple)
                rangesForDetectors.updateValue(ranges, forKey: .date)
            case .phoneNumber:
                var ranges = rangesForDetectors[.phoneNumber] ?? []
                let tuple: (NSRange, MessageTextCheckingType) = (result.range, .phoneNumber(result.phoneNumber))
                ranges.append(tuple)
                rangesForDetectors.updateValue(ranges, forKey: .phoneNumber)
            case .link:
                var ranges = rangesForDetectors[.url] ?? []
                let tuple: (NSRange, MessageTextCheckingType) = (result.range, .link(result.url))
                ranges.append(tuple)
                rangesForDetectors.updateValue(ranges, forKey: .url)
            default:
