Jos*_*erg 26

你可以使用NSDataDetectors这些是在iOS4中添加的,非常有用.你想用它来创建一个数据检测器NSTextCheckingTypeLink并让它做它的事情.

NSString *testString = @"Hello http://google.com world";
NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil];
NSArray *matches = [detect matchesInString:testString options:0 range:NSMakeRange(0, [testString length])];
NSLog(@"%@", matches);
Run Code Online (Sandbox Code Playgroud)