Swift 3, iOS10, Xcode 9
@Sikhapol's answer is really good if you know exactly the words you want to parse, such as a dictionary of words.
it's all about the string itself, which is displayed in a UITextView
My solution is based on text rendering, if you make UITextView display HTML tags, you can use href tag.
Here are some code links you can use
First you need to configure a UITextView from the interface constructor or form code for
- The choice
- Detector Data
Note: do not make the text view editable
Interface constructor

programmatically
let htmlData = NSString(string: "go to <a href=\"http://www.google.com\">google</a> and search for it").data(using: String.Encoding.unicode.rawValue) let attributedString = try! NSAttributedString(data: htmlData!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) yourUIViewView.isSelectable = true yourUIViewView.dataDetectorTypes = .link yourUIViewView.attributedText = attributedString yourUIViewView.delegate = self
for UITextViewDelegate
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
source share