title: How to detect anchor tag link click in NSAttributedString created from html string
body: <p>I am creating NSAttributedString by using html:</p>
  
  <pre><code>let htmlString = "&lt;body style='padding-left:50px'&gt;&lt;h1&gt;Hello World&lt;/h1&gt;&lt;div&gt;&lt;a href=https://apple.com/offer/samsung-faq/&gt;Click Here&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This is a sample text&lt;/p&gt;&lt;pre&gt;This is also sample pre text&lt;/pre&gt;&lt;/body&gt;"
  </code></pre>
  
  <p>And here i am setting it to UILabel by using extension method</p>
  
  <pre><code>someLabel.attributedText = htmlString.htmlToAttributedString
  </code></pre>
  
  <p>NSAttributedString Extension:</p>
  
  <pre><code>extension String {
      var htmlToAttributedString: NSAttributedString? {
          guard let data = data(using: .utf8) else { return NSAttributedString() }
          do {
              return try NSAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType:  NSAttributedString.DocumentType.html], documentAttributes: nil)
          } catch {
              return NSAttributedString()
          }
      }
  }
  </code></pre>
  
  <p>Here i want an callback method to detect link which is there in html string as anchor tag.
  How will i get an event on click and how can i get the url in that event callback ?</p>
  
  <p>Please help...</p>