I have text in a TextView, there are some words in the text, in the case when the user clicks on it, an alert should appear with a word, which for example can mean a word translation into some language.

I tried to use a dictionary, where the key is the word in the text, and the word in the alert is a value. But it does not work. There is an alert with the wrong word.

```
import UIKit

class ViewController: UIViewController , UITextViewDelegate    {
    private let kURLString = "https://www.mywebsite.com"

    let dictionary = ["website" : "Johny" , "visit" : "Bilbo"]

    var keyOne : String?
    var valueOne : String?

    @IBOutlet weak var text: UITextView! {
        didSet{
            text.delegate = self
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let originalText = "Please visit the website for more information."
        let attributedOriginalText = NSMutableAttributedString(string: originalText)

        for (key , value) in dictionary {
            keyOne = key
            valueOne = value
            let linkRange = attributedOriginalText.mutableString.range(of: keyOne!)
            attributedOriginalText.addAttribute(.link, value: kURLString, range: linkRange)

        }

        text.attributedText = attributedOriginalText    
    }

    func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool {
        if (URL.absoluteString == kURLString) {
            alert(value: valueOne!)
        }
        return false
    }

    func alert (value : String) {
         let alert = UIAlertController (title: nil, message: value, preferredStyle: .alert)

         let restartAction = UIAlertAction(title: "Ок", style: .default , handler : { (UIAlertAction) in
            self.viewDidLoad()
         })

         alert.addAction(restartAction)

         present(alert, animated: true, completion: nil)
    }
}

```