最佳答案
您可以使用 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);
关于iphone - Objective-C:如何检测字符串中的 http URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7014119/