Their is a very Simple way in which we can easily get the Url from A String.

  NSString *testString = @”Hello http://google.com world example”;

 NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil];

 NSArray *matches = [detect matchesInString:testString options:0 range:NSMakeRange(0, [testString length])];

 for (NSTextCheckingResult *match in matches) {

 if ([match resultType] == NSTextCheckingTypeLink) {

 url = [match URL];

NSLog(@”The url is %@”,url);

 }

 }

 

Advertisements