0

I have a comments section in my app, where users can tag their friends. When loading the comments into the table view, I need to parse through each comment to see if it contains the @ signal for a tagged friend, then get that substring and convert it to a UIButton that segues to the user's profile.

I already have textLabel?.text as String?, but I'm unsure of how to convert a substring of String? to a UIButton. Do I have to use an attributed string?

slider
  • 2,736
  • 4
  • 33
  • 69

1 Answers1

2

If you need custom detection and if you want to be able to call any custom method after a user clicks on a particular word, you should first make your UITextView selectable and then check out NSAttributedStrings with an NSLinkAttributeName attribute that will point to a custom URL scheme. Go through this Ray Wenderlich article

tmac_balla
  • 648
  • 3
  • 16