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      



    }

  }
相关文章
相关标签/搜索