Hyperlinks in iOS App by detecting Links, Phone Number, Address and CalendarEvent in UITextView
In many scenarios we have to detect Links(URLs) and Phone Numbers from given NSString and make it similar to hyperlink in HTML. Suppose you have a string with multiple url's and you want to make it clickable, so as to be able to open it in Safari browser. In below code i have taken a string which consists of two url's and i want to make it clickable. So i take a UITextView "txtViewClickableHyperLink" and assigned the NSString "strText" to it. Now i have used a magic line to setDataDetector of UITextView, this line has power to recognise my url. By changing type of DataDetector we can recognise: UIDataDetectorTypeLink - URL (Link) UIDataDetectorTypePhoneNumber - Phone Number UIDataDetectorTypeAddress - Address UIDataDetectorTypeCalendarEvent - Calendar Event UIDataDetectorTypeAll - De...