NSDataDetector数据检测器,检测是否是链接
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:&error];//创建检测器,检测类型是linke(可改成检测别的) NSArray *matches = [detector matchesInString:textString options:0 range:NSMakeRange(0, textString.length)];//检测字符串 for (NSTextCheckingResult *match in matches) { if ([match resultType] == NSTextCheckingTypeLink) { NSRange matchRange = [match range];
//do something } }
posted on 2015-04-06 20:44 wangyutao0424 阅读(578) 评论(0) 编辑 收藏 举报