In the below code I am detecting the url from string. now I need to put hyperlink only to detected "url" and assign to UILabel
whenever I click on this url it should go to browser, how to do this?
Code:
NSString *string = descPost.text;
NSDataDetector *linkDetector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil];
NSArray *matches = [linkDetector matchesInString:string options:0 range:NSMakeRange(0, [string length])];
for (NSTextCheckingResult *match in matches)
{
if ([match resultType] == NSTextCheckingTypeLink)
{
NSURL *url = [match URL];
NSLog(@"found URL: %@", url);
}
}